Address Property Example

This example adds a hyperlink to the selection in the active document, sets the address, and then displays the address in a message box.

Set aHLink = ActiveDocument.Hyperlinks.Add( _
    Anchor:=Selection.Range, _
    Address:="http://forms")
MsgBox "The hyperlink goes to " & aHLink.Address

If the active document includes hyperlinks, this example inserts a list of the hyperlink destinations at the end of the document.

Set myRange = ActiveDocument _
    .Range(Start:=ActiveDocument.Content.End - 1)
Count = 0
For Each aHyperlink In ActiveDocument.Hyperlinks
    Count = Count + 1
    With myRange
        .InsertAfter "Hyperlink #" & Count & vbTab
        .InsertAfter aHyperlink.Address
        .InsertParagraphAfter
    End With
Next aHyperlink

This example displays the delivery address if an envelope has been added to the document; otherwise, it displays a message.

On Error GoTo errhandler
addr = ActiveDocument.Envelope.Address.Text
MsgBox Prompt:=addr, Title:="Delivery Address"
errhandler:
If Err = 5852 Then MsgBox "Insert an envelope into the document"