HyperlinkByID Method

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

Syntax

[[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.

Remarks

If the hyperlink with the specified hyperlinkID wasn't found in the document, the method returns Nothing.

Example

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

 

See Also

ID property, Hyperlink property, AddHyperlinkToDocument method, AddHyperlinkToFile method, AddHyperlinkToPageShape method, AddHyperlinkToURL method, Hyperlink method, HyperlinksNum method, RemoveUnusedHyperlinks method, Hyperlink object