Returns the number of hyperlinks in the hyperlink collection of the document.
Applies to: Document object
[[Let] countRet =] object.HyperlinksNum () |
The HyperlinksNum method syntax has these parts:
Part | Description |
object | Required. An expression, that returns an instance of the Document object. |
countRet | Optional. A Long type variable. |
Note, that the number of hyperlinks is increased when new hyperlinks are added to the collection and is decreased when unused hyperlinks are deleted (see the RemoveUnusedHyperlinks method). If there are no hyperlinks in the document, the HyperlinksNum method returns 0.
This example contains a document-level script. The script calculates the number of hyperlinks in the hyperlink collection of the document for each of the three hyperlink types: cdLinkToFile, cdLinkToURL, cdLinkToPageShape. The results of the calculation and the total number of hyperlinks in the document are displayed on the screen.
' Declare variables Dim n_LinkToFile As Integer Dim n_LinkToUrl As Integer Dim n_LinkToPageShape As Integer ' Initialize counters with zeros n_LinkToFile = 0 n_LinkToUrl = 0 n_LinkToPageShape = 0 ' Loop through all hyperlinks in the hyperlink ' collection of the document For i=1 To thisDoc.HyperlinksNum() ' Calculate the amount of hyperlinks of each type Select Case thisDoc.Hyperlink(i).LinkType Case cdLinkToFile n_LinkToFile = n_LinkToFile + 1 Case cdLinkToURL n_LinkToUrl = n_LinkToUrl + 1 Case cdLinkToPageShape n_LinkToPageShape = n_LinkToPageShape + 1 End Select Next i ' Display the results TRACE "Number of:" TRACE "Links to file = " & n_LinkToFile TRACE "Links to URL = " & n_LinkToUrl TRACE "Links to Page Or Shape = " & n_LinkToPageShape TRACE "Total number of links = " & thisDoc.HyperlinksNum() |