PDA

View Full Version : [SOLVED] Link to Word document



gmaxey
06-19-2014, 11:57 AM
I have some code that adds a hyperlink to a cell the hyperlink address and display is the path and file name of a Word document:


xlSheet.Hyperlinks.Add .Cells(lngRecordCount, 12), _
Address:="", SubAddress:=strPN, TextToDisplay:=strPN

Where strPN might be C:\My Documents\Test.docm

I would like to be able to click that hyperlink and the Word document then open in Word. It doesn't work (likely isn't supposed to). Can anyone advise how I could achieve the goal via other means? I want to be able to click in a cell and as a result Word will open to the document referenced in the cell. Thanks.

mancubus
06-20-2014, 12:59 AM
hi Greg.

this worked for me.




With xlSheet
.Hyperlinks.Add Anchor:=.Cells(lngRecordCount, 12), Address:=strPN
End With

gmaxey
06-20-2014, 05:39 AM
mancubus,
Perfect! Thanks, I don't know where I got that "Address", "Subaddress" idea from.

mancubus
06-20-2014, 06:14 AM
you are welcome.

even though we know hot to code a requirement, free/paid internet resources may enable us complete a project in a short(er) time period

and sometimes copy-paste errors occur. :)

sometimes we omit adopting all but one line in the code too.

Paul_Hossler
06-20-2014, 10:26 AM
Greg -- I believe that you would use the Subaddress if you wanted to go to a bookmark in the Word document