Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating Hyperlink using VBA

Status
Not open for further replies.

pvcc

Technical User
Sep 9, 2004
6
US
I'm trying to create a hyperlink in one Workbook to open a second workbook. As part of the code i have the follwoing lines:
strFileName = "SmithJobDesc.xls"
Activesheet.Hyperlink.Add Anchor:=Selection,Address=strFileName,TestToDisplay="Position"
When the code is run a hyperlink is created in one workbook.
I moved the two workbooks to a folder on another user's machine (one workbook with the hyperlink and the other to be opened by it) and click the hyperlink I get the message "the address of the site is not valid". when I check the address in Excel (Edit Hyperlink) the address displayed is ../SmithJobDesc.xls
When I set up a parent directory and place one workbook in it the Hyperlink works. My goal is to keep both files in the same folder. How do I modify the VBA code so the ../ is not part of the Hyperlink address.

Thanks

Roy
 
Hi pvcc,

Where were the two workbooks when you created the hyperlink? I just ran your code with two workbooks in the same folder and moved them both to a different folder on a different machine and it all worked just fine.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Tony, the files weren't in the same folder when the hyperlink was originally created. When the hyperlink was created with both files in the same folder the hyperlink opens the second workbook.

Thanks for your help,
Roy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top