Hyperlinks.Add method (Word)

Returns a Hyperlink object that represents a new hyperlink added to a range, selection, or document.

Syntax

expression.Add (Anchor, Address, SubAddress, ScreenTip, TextToDisplay, Target)

expression Required. A variable that represents a 'Hyperlinks' collection.

Parameters

Name Required/Optional Data type Description
Anchor Required Object The text or graphic that you want turned into a hyperlink.
Address Optional Variant The address for the specified link. The address can be an email address, an Internet address, or a file name. Note that Microsoft Word doesn't check the accuracy of the address.
SubAddress Optional Variant The name of a location within the destination file, such as a bookmark, named range, or slide number.
ScreenTip Optional Variant The text that appears as a ScreenTip when the mouse pointer is positioned over the specified hyperlink. The default value is "Address".
TextToDisplay Optional Variant The display text of the specified hyperlink. The value of this argument replaces the text or graphic specified by Anchor.
Target Optional Variant The name of the frame or window in which you want to load the specified hyperlink.

Return value

Hyperlink

Example

This example turns the selection into a hyperlink to the Microsoft address on the World Wide Web.

ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, _ 
 Address:="http:\\www.microsoft.com"

This example turns the selection into a hyperlink that links to the bookmark named MyBookMark in MyFile.doc.

ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, _ 
 Address:="C:\My Documents\MyFile.doc", SubAddress:="MyBookMark"

This example turns the first shape in the selection into a hyperlink.

ActiveDocument.Hyperlinks.Add Anchor:=Selection.ShapeRange(1), _ 
 Address:="http:\\www.microsoft.com"

See also

Hyperlinks Collection Object

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.