PDA

View Full Version : HyperLinks to specific Location in another App.



stevebrugel
03-23-2011, 01:54 PM
I have found some similar thread regarding this issue, but none that seem to tackle it. I am trying to add a hyperlink to excel that will open a Word Doc to a specific location (say for instance, open to pg 32 paragraph 3. I have found the add function that looks like this,
ActiveCell.Hyperlinks.Add ActiveCell, "C:\XL.docx", "\s 1,6167,6168,0,,a", "Takes You there", "ABCD"
This opens the Document but does NOT take me to the desired location.
If I manually copy a word or object in WORD and pasteSpecial as Hyperlink in Excel, the hyperlink functions as expected, But I want to do this with VBA.
The macro recorder gives no help if I try recording the steps. Anyone have some insight on this.

Steve

mdmackillop
03-23-2011, 02:56 PM
This should go to Page 6 , Line 12 of the target document

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

Dim wd As Object
Dim Doc As Object
Set wd = GetObject(, "Word.Application")
Set Doc = wd.documents(1)
wd.Selection.GoTo What:=1, Which:=2, Name:="6"
wd.Selection.GoTo What:=3, Which:=2, Count:=12
End Sub