wotter
wotter

Reputation: 528

Where is the hyperlink in the word document?

I am trying to make a list of hyperlinks and append the location inside the document of each hyperlink, and if possible the position inside the page (line number?)

e.g. https://stackoverflow.com ........... Page 234 Line 58

I know how to get the hyperlinks from the Document object

Dim objDoc As Document
Dim i As Integer
Set objDoc = Documents.Open(FileName:=sUri)
For i = 1 To objDoc.Hyperlinks.Count
     debug.print objDoc.Hyperlinks(i).Address
next i

but I cannot find a property that tells me where the link is in the document. Any idea?

Upvotes: 0

Views: 456

Answers (1)

wotter
wotter

Reputation: 528

Thanks to @ahmed-au links, I found that the following gave me the page number:

objDoc.Hyperlinks(i).Range.Information(wdActiveEndPageNumber)

and the line number:

objDoc.Hyperlinks(i).Range.Information(wdFirstCharacterLineNumber)

The codes to use to get the various informations about the range selected are on this Microsoft page: https://learn.microsoft.com/office/vba/api/word.wdinformation

Upvotes: 2

Related Questions