Adds a hyperlink pointing to a file to the hyperlink collection of the document. Returns the ID (ID property) of the added hyperlink.
Applies to: Document object
[[Let] linkIDRet = ] object.AddHyperlinkToFile ( filename, [localPath] ) |
The AddHyperlinkToFile method syntax has these parts:
Part | Description |
object | Required. An expression that returns an instance of the Document object. |
fileName | Required. An expression that returns a String value. Specifies the filename (with the full or relative path) to which the added hyperlink will point. |
localPath | Optional. An expression that returns a Boolean value. If localPath is True, then the fileName represents a relative path (with respect to the folder, in which the document is located). Otherwise fileName contains the full path to the file. The default value is False. |
linkIDRet | Optional. A Long type variable. |
If the hyperlink was added successfully, the AddHyperlinkToFile method returns the ID of the added hyperlink. If the hyperlink collection of the document already contains a hyperlink with the same properties, the method doesn't create a new hyperlink, but returns the ID of the identical hyperlink. In all other cases the method returns 0.
A hyperlink created with the AddHyperlinkToFile method has the cdLinkToFile type (see the LinkType property).
This example contains a document-level script. The program creates a rectangle that contains a hyperlink pointing to a file, chosen by the user. The hyperlink is added by using the AddHyperlinkToFile method.
' Declare variables |