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 e-mail 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