vba dynamic hyperlink

mendesj1

Registered User.
Local time
Today, 14:46
Joined
Nov 9, 2011
Messages
30
Try to open a pdf with a button in a form using vba - i want it to take the data from me!comp_ID and insert it into the file location and then add .pdf on the end and open it with this i get a type mismatch run time error '13'

Thanks for your help


Dim strfile As String

strfile = "Y:\EMPLOYEE FOLDERS\JMendes stuff\CreditApp\" + Me!COMP_ID + ".pdf"

Application.FollowHyperlink (strfile)
 
Try replacing + (math operator) with & (concatenation operator). If that doesn't work, add

Debug.Print strfile

after it's set so you can see the resulting string in the VBA Immediate window.
 
Thanks worked great!
 
One more question, that works great but is there a way if the file does not exist I can create a pop up telling the user its not there instead of a vba run error
 
You can use the Dir() function to test for the existence of the file.
 

Users who are viewing this thread

Back
Top Bottom