Create hyperlink to external worbook

YasserKhalil
PlatinumLounger
Posts: 4931
Joined: 31 Aug 2016, 09:02

Create hyperlink to external worbook

Post by YasserKhalil »

Hello everyone

I ma trying to loop through closed workbook and in the code I am trying to create a hyperlink to a worksheet that is in the external (closed) workbook ..
This is my try

Code: Select all

ws.Cells(r, 1).Hyperlinks.Add Anchor:=ws.Cells(r, 1), Address:="[" & sPath & sFile & "]", SubAddress:="'" & sh.Name & "'!A1", TextToDisplay:=sh.Name
The code doesn't give any error but the hyperlink is not correct ..

YasserKhalil
PlatinumLounger
Posts: 4931
Joined: 31 Aug 2016, 09:02

Re: Create hyperlink to external worbook

Post by YasserKhalil »

After so many tries I could figure it out

Code: Select all

ws.Hyperlinks.Add Anchor:=ws.Cells(r, 1), Address:=sPath & sFile, SubAddress:="'" & sh.Name & "'!A1", TextToDisplay:=sh.Name