Returns an IHTMLElementCollection collection that represents all anchor elements in the current document that have a specified name and/or ID attribute. Anchor elements correspond to an <A> tag.
expression.anchors
expression Required. An expression that returns one of the objects in the Applies To list.
This collection is indexed first by name, then by identifier. If duplicate names are found, a collection of those named items is returned. Collections of duplicate names must subsequently be referenced by ordinal position.
If the anchor attribute is not set, it does not appear in the collection.
The following example returns the collection of all anchors in the current document and displays the name associated with each element.
Sub AnchorsCollection()
'Returns the collection of all anchor elements in the active document.
Dim objAll As IHTMLElementCollection
'Reference the anchors collection
Set objAll = FrontPage.ActiveDocument.anchors
For i = 0 To objAll.Length - 1
'Display names of all set anchor items in collection
MsgBox "Element name: " & objAll.Item(i).Name
Next i
End Sub