Searches for a hyperlink by the specified ID (the ID property) in the hyperlink collection of the document. Returns an instance of the Hyperlink object, corresponding to the found hyperlink.
Applies to: Document object
[[Set] hyperlinkRet =] object.HyperlinkByID ( hyperlinkID ) |
The HyperlinkByID method syntax has these parts:
Part | Description |
object | Required. An expression, that returns an instance of the Document object. |
hyperlinkID | Required. An expression that returns a Long value. Represents the ID of the hyperlink being searched. |
hyperlinkRet | Optional. A Hyperlink type variable. |
If the hyperlink with the specified hyperlinkID wasn't found in the document, the method returns Nothing.
This example contains a page-level script. It displays the list of all hyperlinks which exist on the page (thisPage). The HyperlinkByID method is used to search for the hyperlink by the hyperlink ID taken from the shape (see the Hyperlink property).
' Declare variables Dim linkID As Long Dim hlink As Hyperlink ' Loops though all shapes on the page (thisPage) For i=1 To thisPage.ShapesNum() ' Get ID of the shape's hyperlink linkID = thisPage.Shape(i).Hyperlink ' Search for hyperlink with specified ID in the hyperlink ' collection of the document Set hlink = thisDoc.HyperlinkByID( linkID ) If hlink <> Null Then ' If hyperlink found, display its properties TRACE "Shape_" & i & " " & hlink TRACE " ID = " & hlink.ID TRACE " LinkType = " & hlink.LinkType TRACE " Address = " & hlink.Address TRACE " LocalPath = " & hlink.LocalPath TRACE " PageID = " & hlink.PageID TRACE " ShapeID = " & hlink.ShapeID End If Next i |