• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

User form - Adding a PNG and a path to the file |VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / User form - Adding a PNG and a path to the file |VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosUser form - Adding a PNG and a path…
sp_PrintTopic sp_TopicIcon
User form - Adding a PNG and a path to the file
Avatar
Brian Titus
Member
Members
Level 0
Forum Posts: 8
Member Since:
February 8, 2020
sp_UserOfflineSmall Offline
1
August 10, 2020 - 6:39 pm
sp_Permalink sp_Print sp_EditHistory

Hi MOH community

First off - what I know about VBA is scary.

I have been watching the video on creating a userform that Philip uploaded in 2015. I can amend this workbook to suite my needs. Additional feature I wou like to add is when the expense entry has a "before" file to be attached and then when it is approved and "after" and when it is paid a "paid" stamp.

Is it possible to browse and upload these stages of the expenses to the userform?

Then when you click on the hyperlink of the file it will open the .png and also take you to the file location.

All of this information will be stored on my hard drive and won't be shared across a network.

I thought that this video about the hyperlink will solve my ask but not quit sure how to make the upload feature work or even opening the file location.

I have attached the latest file from Philip - I have not changed anything on this file - just studying it to see how I could incorporating the functionality above.

The attached expenses file is where I have started to make the amendments.

Hope that is in order.

Regards

Brian

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1807
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
2
August 18, 2020 - 1:12 pm
sp_Permalink sp_Print

Hi Brian,

The stages are not uploaded to user form, I guess you just want to display a link to those files in the userform.
Add a label with the file full path, then for that label, the code should be:

Private Sub Label1_Click()

Shell "explorer.exe " & Label1.Caption

End Sub

When you will click that label in userform, the file should open.
The file you have uploaded cannot be downloaded so I was not able to modify your file.

Avatar
Brian Titus
Member
Members
Level 0
Forum Posts: 8
Member Since:
February 8, 2020
sp_UserOfflineSmall Offline
3
August 18, 2020 - 7:27 pm
sp_Permalink sp_Print

Hi Catalin

I have progressed this a little. I have attached the latest version of what I am trying to build.

Loading pictures: In this user form I have placeholders for 4 charts. Through the good old internet - I have a code in there to get the first picture loaded and it works. Now do I have to create a private sub get image 3 more times to get the images for the other 3 charts? chart 1 and chart 2 could be in the same folder on my workbook. Chart 3 will be in its own folder and Chart 4 will be in its own folder. Alternatively is there some clever way to make the existing private sub get image function loop through each chart?

Chart location: I have a label working which opens the folder where the chart is saved. Your suggestion seems better in that I don't have to look for that chart in the folder if I want to view it. Thing is I don't know how to edit the existing code with yours please help.

Formulas: I have formulas in my workbook - orange highlighted cells - which work fine when I work in the table in the workbook. However when I open the useform and then close it - the formulas get overwritten. Have you come across this before?

Regards

Brian

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1807
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
4
August 19, 2020 - 1:29 am
sp_Permalink sp_Print sp_EditHistory

Added in the file attached a new version of GetImage procedure.

If you don't want code to overwrite table formulas, then just remove those lines of code that are writing in those columns:

' .Cells(1, 9) = txtEntryFilledShares.Value ' add an apostrophy at the beginning of this line to disable it
Avatar
Brian Titus
Member
Members
Level 0
Forum Posts: 8
Member Since:
February 8, 2020
sp_UserOfflineSmall Offline
5
August 20, 2020 - 3:51 am
sp_Permalink sp_Print

Hi Catalin

When I go to utilise the form I get the following error message:

Compile error, Sub or function not defined and ShowImages is highlighted.

 

Private Sub UserForm_Initialize()

Set TradeJournalTable = ActiveSheet.ListObjects("TradeJournal")

'Initialise for empty table
ChangeRecord.Min = 0
ChangeRecord.Max = 0

CurrentRow = TradeJournalTable.ListRows.Count

If CurrentRow > 0 Then

ChangeRecord.Min = 1
ChangeRecord.Max = TradeJournalTable.ListRows.Count

'Load last record into form
PopulateForm TradeJournalTable.ListRows(TradeJournalTable.ListRows.Count).Range
TradeJournalTable.ListRows(TradeJournalTable.ListRows.Count).Range.Select

UpdatePositionCaption

Else

RecordPosition.Caption = "0 of 0"

End If

ShowImages

End Sub

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1807
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
6
August 20, 2020 - 1:00 pm
sp_Permalink sp_Print

Just delete that line, that procedure does not exist anymore.

Avatar
Brian Titus
Member
Members
Level 0
Forum Posts: 8
Member Since:
February 8, 2020
sp_UserOfflineSmall Offline
7
August 22, 2020 - 4:13 pm
sp_Permalink sp_Print

Hi Catalin

Thanks for the above.

Can you please help with the Getimage sub.

I think the right and value functions is not creating the correct number of either 1,2,3 or 4 to append to image later in the sequence.

The image is not loading nor do I get an error message.

Thanks in advance

brian

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1807
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
8
August 22, 2020 - 10:02 pm
sp_Permalink sp_Print

This line should be updated:
ChName = Right(Ctl.Name, Len(Ctl.Name) - InStr(Ctl.Name, "Chart"))

replace it with:
ChName = Right(Ctl.Name, Len(Ctl.Name) - InStr(Ctl.Name, "Chart")+1)

Avatar
Brian Titus
Member
Members
Level 0
Forum Posts: 8
Member Since:
February 8, 2020
sp_UserOfflineSmall Offline
9
August 23, 2020 - 3:52 pm
sp_Permalink sp_Print

Hi Catalin

Still no joy.

what is the formula meant to do?

if the control name is tbtExitChart3Name.Value
what is the corrcet answer to this formula,

ChName = Right .... = 17 - 6 + 1 = 12

and when we replace stuff

ChName = Val ... = 0

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1807
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
10
August 23, 2020 - 4:51 pm
sp_Permalink sp_Print sp_EditHistory

Hi Brian,

Just for accuracy, the control name does not contain .Value, that is the method that extracts the value of that control.

This line:

Right("tbtExitChart3Name", Len("tbtExitChart3Name") - InStr("tbtExitChart3Name", "Chart")+1)

will return: "Chart3Name" , it's not meant to make math operations, it's doing text string manipulation.
It's very similar to this excel formula, you can try this in a cell: =RIGHT("tbtExitChart3Name", LEN("tbtExitChart3Name") - FIND("Chart","tbtExitChart3Name")+1)

The only difference is that in vba we use InStr instead of FIND.

Without being able to test it without images and folders you have, I think it returns the correct values now.

You can try with

ChName = R eplace(R eplace(ChName, "Chart", ""), "Name", "")

Please try to provide an error message, "still no joy" does not seem to be very descriptive 🙂

Avatar
Brian Titus
Member
Members
Level 0
Forum Posts: 8
Member Since:
February 8, 2020
sp_UserOfflineSmall Offline
11
August 23, 2020 - 6:00 pm
sp_Permalink sp_Print

Hi Catalin

Thank you for that explanation.

Then I suppose the next line of code will remove the Chart and Name from Chart3Name to leave us with a nummber in this case 3.

Thing is when I run the code / initialise the form - I do not get an error message - the placeholder/ image for the picture is just blank. Please see the example attached.

Unless there is something else I should be meant to do?

Regards

Brian

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1807
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
12
August 24, 2020 - 3:21 pm
sp_Permalink sp_Print

Found my mistake, sorry:

If Ctl.Name Like "Chart*Name" Then
should be:
If Ctl.Name Like "*Chart*Name" Then

Avatar
Brian Titus
Member
Members
Level 0
Forum Posts: 8
Member Since:
February 8, 2020
sp_UserOfflineSmall Offline
13
August 24, 2020 - 5:58 pm
sp_Permalink sp_Print sp_EditHistory

Hi Catalin

Thank you for getting back to me.

I made the changes in the private sub GetImage(). I went to run the macro and now it falls over at the first hurdle with a run time error 76. Path not found.

When I go to debug it takes me to the Sub ShowTradeJournalForm() and the only thing in there highligted in yellow is TradeJournalForm.Show

This Sub sits in the Modules section.

Pressing and holding F8 - just brings me back to this Sub. Any amendments you can suggest here?

Thanks in advance

Brian

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1807
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
14
August 25, 2020 - 1:18 pm
sp_Permalink sp_Print

Make sure the path used in your code is correct.

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Jack Brett, Martyn Cheney, Rocco Pinneri, Benny Nielsen, LAFONSO HERNANDEZ
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
LAFONSO HERNANDEZ
Hayden Hao
Angela chen
Sean Moore
John Chisholm
vexokeb sdfg
John Jack
Malcolm Toy
Ray-Yu Yang
George Shihadeh
Forum Stats:
Groups: 3
Forums: 24
Topics: 6211
Posts: 27239

 

Member Stats:
Guest Posters: 49
Members: 31891
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.