AddHyperlinkToURL Method

Adds a hyperlink pointing to URL (an Internet address) to the hyperlink collection of the document. Returns the ID (the ID property) of the added hyperlink.

Applies to: Document object

Syntax

[[Let] linkIDRet = ] object.AddHyperlinkToURL ( url )

The AddHyperlinkToURL method syntax has these parts:

Part Description
object Required. An expression that returns an instance of the Document object.
url

Required. An expression that returns a String value. Specifies the URL address of the resource to which the added hyperlink will point.

linkIDRet Optional. A Long type variable.

Remarks

If the hyperlink was added successfully, the AddHyperlinkToURL 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 AddHyperlinkToURL method has the cdLinkToURL type (see the LinkType property).

Example

This example contains a document-level script. The program adds a hyperlink pointing to the ConceptDraw web site (www.conceptdraw.com) to the hyperlink collection of the document. Then the user can input the ID of the shape in the document, to which the created hyperlink will be assigned. The hyperlink is added by using the AddHyperlinkToURL method.AddHyperlinkToURL.

' Declare variables
Dim shp As Shape
Dim cur_page As Page
Dim shapeID As Long
Dim hlinkID As Long


' Add hyperlink pointing to the ConceptDraw web site to the 
' hyperlink collection of the document
hlinkID = thisDoc.AddHyperlinkToURL( "www.conceptdraw.com" ) ' Ask the user to input the ID of the shape to which the hyperlink will be assigned. shapeID = InputBox( "Enter the ID of the shape to assign the hyperlink to:" ) ' Loop through all pages of the document, until the shape with the provided ID is found.
' Assign the hyperlink to that shape. For i=1 To thisDoc.PagesNum() ' Look for the shape with provided ID in the shape collection of the document. Set shp = thisDoc.Page(i).ShapeByID( shapeID ) ' If the shape is found, assign the hyperlink to it. If shp <> Null Then shp.Hyperlink = hlinkID shp.DblClick = 4 End If Next i

 

See Also

ID property, LinkType property, AddHyperlinkToDocument method, AddHyperlinkToFile method, AddHyperlinkToPageShape method, Hyperlink method, HyperlinkByID method, HyperlinksNum method, RemoveUnusedHyperlinks method, Hyperlink object