Hyperlink.Address problem (1 Viewer)

suzeg

Registered User.
Local time
Today, 12:51
Joined
Jun 20, 2012
Messages
27
I am trying to open an excel file using the following code.
Code:
 lblLotPlan.HyperlinkAddress = ""
 lblLotPlan.HyperlinkAddress = ("Old Cemetary\" & "Lot " & tmplotno & ".xls")
 Application.FollowHyperlink lblLotPlan.HyperlinkAddress
tmplotno is a string
The file will open fine if I type the entire path in however; the folder and filenames will be variable.
I get the error '490' - Cannot open the specified file.

I am using the exact same code to open a .pdf and a .jpg file and they work perfectly.

Help would be greatly appreciated. :)
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:51
Joined
Aug 30, 2003
Messages
36,118
For starters, I would expect the path to start with either a drive or UNC path. In other words:

C:\Old Cemetary\...

or

\\ServerName\Old Cemetary\
 

suzeg

Registered User.
Local time
Today, 12:51
Joined
Jun 20, 2012
Messages
27
Thanks - I had tried so many iterations but just realized the error was in the extension. Which now begs another question.
The files are .xls my test file was .xlsx.
How can I write the hyperlink address so that it will open a file whether it is .xlsx or .xls?
 

Users who are viewing this thread

Top Bottom