Share via


links Property

Returns an IHTMLElementCollection collection that represents the collection of hyperlinks in a page.

expression.links

*expression   * Required. An expression that returns one of the objects in the Applies To list.

Example

The following example loops through all the hyperlinks in the active document and adds an id attribute to it.

Sub LoopThroughLinks()
    Dim objLink As FPHTMLAnchorElement
    Dim intCount As Integer
    Dim objLinks As IHTMLElementCollection
    
    Set objLinks = ActiveDocument.Links
    
    For intCount = 0 To objLinks.Length - 1
        Set objLink = objLinks.Item(intCount)
        
        objLink.Id = "hyperlink" & intCount + 1
    Next
End Sub

Applies to | FPHTMLDocument Object | IHTMLDocument2 Object