Add Method (Hyperlinks Collection)

Applies To

Hyperlinks collection object.

Description

Adds a new hyperlink to the document, selection, or range.

Syntax

expression.Add(Anchor, Address, SubAddress)

expression Required. An expression that returns a Hyperlinks object.

Anchor Required Object. The text or graphic that you want turned into a hyperlink.

Address Optional Variant. The address for the link. The address can be an e-mail address, an Internet address, or a file name. Note that 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.

See Also

AutoFormatAsYouTypeReplaceHyperlinks property, AutoFormatReplaceHyperlinks property, FollowHyperlink method, Hyperlinks property.

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"