Hyperlink object (Publisher)
Represents a hyperlink. The Hyperlink object is a member of the Hyperlinks collection and the Shape and ShapeRange objects.
Remarks
Use the Shape.Hyperlink property to return a Hyperlink object associated with a shape (a shape can have only one hyperlink).
Use Hyperlinks (index), where index is the index number, to return a single Hyperlink object from a document, range, or selection.
Use the Add method to add a hyperlink.
Use the Address property to add or change the address to a hyperlink.
Example
The following example deletes the hyperlink associated with the first shape in the active document.
Sub DeleteHyperlink()
ActiveDocument.Pages(1).Shapes(1).Hyperlink.Delete
End Sub
The following example deletes the first hyperlink in the selection.
Sub DeleteSelectedHyperlink()
If Selection.TextRange.Hyperlinks.Count >= 1 Then
Selection.TextRange.Hyperlinks(1).Delete
End If
End Sub
The following example adds a hyperlink to the selected text.
Sub AddHyperlinkToSelectedText()
Selection.TextRange.Hyperlinks.Add Text:=Selection.TextRange, _
Address:="https://www.tailspintoys.com/"
End Sub
The following example adds a shape to the active publication and then adds a hyperlink to the shape.
Sub AddHyperlinkToShape()
With ActiveDocument.Pages(1).Shapes.AddShape _
(Type:=msoShape5pointStar, Left:=200, _
Top:=200, Width:=300, Height:=300)
.Hyperlink.Address = "https://www.tailspintoys.com/"
End With
End Sub
Methods
Properties
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.