February 8, 2020
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
Power Query
Power Pivot
Xtreme Pivot Tables
Excel for Decision Making
Excel for Finance
Excel Analysis Toolpak
Power BI
Excel
Word
Outlook
Excel Expert
Excel Customer Service
PowerPoint
November 8, 2013
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.
February 8, 2020
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
Power Query
Power Pivot
Xtreme Pivot Tables
Excel for Decision Making
Excel for Finance
Excel Analysis Toolpak
Power BI
Excel
Word
Outlook
Excel Expert
Excel Customer Service
PowerPoint
November 8, 2013
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:
February 8, 2020
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
Power Query
Power Pivot
Xtreme Pivot Tables
Excel for Decision Making
Excel for Finance
Excel Analysis Toolpak
Power BI
Excel
Word
Outlook
Excel Expert
Excel Customer Service
PowerPoint
November 8, 2013
February 8, 2020
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
Power Query
Power Pivot
Xtreme Pivot Tables
Excel for Decision Making
Excel for Finance
Excel Analysis Toolpak
Power BI
Excel
Word
Outlook
Excel Expert
Excel Customer Service
PowerPoint
November 8, 2013
Power Query
Power Pivot
Xtreme Pivot Tables
Excel for Decision Making
Excel for Finance
Excel Analysis Toolpak
Power BI
Excel
Word
Outlook
Excel Expert
Excel Customer Service
PowerPoint
November 8, 2013
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
Please try to provide an error message, "still no joy" does not seem to be very descriptive 🙂
February 8, 2020
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
Power Query
Power Pivot
Xtreme Pivot Tables
Excel for Decision Making
Excel for Finance
Excel Analysis Toolpak
Power BI
Excel
Word
Outlook
Excel Expert
Excel Customer Service
PowerPoint
November 8, 2013
February 8, 2020
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
1 Guest(s)