# Function Reference

# _Word_DocLinkGet

Returns a collection object containing all links in the document or a single link object

#include <Word.au3>
_Word_DocLinkGet ( $oDoc [, $iIndex = Default] )

## Parameters

$oDoc | Word document object
$iIndex | [optional] Specifies what to return: Default - Returns a collection of all links (default) n - The index number of the link to return (1 based)

## Return Value

Success: | a variable pointing to the collection of links or a single link object. @extended is set to the total number of links
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $oDoc is not an object 2 - $iIndex is invalid (must be an integer > 0 and <= Hyperlinks.Count) or the keyword Default 3 - Error occurred when accessing the Hyperlinks collection. @extended is set to the COM error code

## Related

_Word_DocLinkAdd

## Example

### Example 1

    #include "Extras\HelpFileInternals.au3"

    #include <MsgBoxConstants.au3>
    #include <Word.au3>

    ; Create application object
    Local $oWord = _Word_Create()
    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkGet Example", _
            "Error creating the Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    ; Open test.doc read-only
    Local $oDoc = _Word_DocOpen($oWord, _Extras_PathFull("Test.doc"), Default, Default, True)
    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkGet Example", "Error opening '.\Extras\Test.doc'. @error = " & _
            @error & ", @extended = " & @extended)

    ; Get the collection of hyperlinks and display some properties
    Local $oLinks = _Word_DocLinkGet($oDoc)
    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkGet Example", _
            "Error accessing link collection of the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    Local $sResult = "Total number of hyperlinks in the document: " & @extended & @CRLF & @CRLF
    For $oLink In $oLinks
        $sResult = $sResult & "Text: " & $oLink.TextToDisplay & @CRLF & "Address: " & $oLink.Address & _
                @CRLF & "------------------------------------------" & @CRLF
    Next
    MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkGet Example - Process all hyperlinks", $sResult)

### Example 2

    #include "Extras\HelpFileInternals.au3"

    #include <MsgBoxConstants.au3>
    #include <Word.au3>

    ; Create application object
    Local $oWord = _Word_Create()
    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkGet Example", _
            "Error creating the Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    ; Open test.doc read-only
    Local $oDoc = _Word_DocOpen($oWord, _Extras_PathFull("Test.doc"), Default, Default, True)
    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkGet Example", "Error opening '.\Extras\Test.doc'. @error = " & _
            @error & ", @extended = " & @extended)

    ; Return hyperlink number 2 and display some properties
    Local $oLink = _Word_DocLinkGet($oDoc, 2)
    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkGet Example", _
            "Error accessing link collection of the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    Local $sResult = "Total number of hyperlinks in the document: " & @extended & @CRLF & @CRLF & _
            "Text: " & $oLink.TextToDisplay & @CRLF & _
            "Address: " & $oLink.Address & @CRLF & _
            "Screentip: " & $oLink.Screentip
    MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkGet Example - Process hyperlink #2", $sResult)