OpenLinks Method

Microsoft Excel Visual Basic

OpenLinks Method

       

Opens the supporting documents for a link or links.

expression.OpenLinks(Name, ReadOnly, Type)

expression   Required. An expression that returns one of the objects in the Applies To list.

Name  Required String.  The name of the Microsoft Excel or DDE/OLE link, as returned from the LinkSources method.

ReadOnly  Optional VariantTrue to open documents as read-only. The default value is False.

Type  Optional XlLink.  The link type.

XlLink can be one of these XlLink constants.
xlExcelLinks
xlOLELinks (also handles DDE links)

xlPublishers

xlSubscribers

Example

This example opens OLE link one in the active workbook.

linkArray = ActiveWorkbook.LinkSources(xlOLELinks)
ActiveWorkbook.OpenLinks linkArray(1)

This example opens all supporting Microsoft Excel documents for the active workbook.

Sub OpenAllLinks()
    Dim arLinks As Variant
    Dim intIndex As Integer
    arLinks = ActiveWorkbook.LinkSources(xlExcelLinks)
   
    If Not IsEmpty(arLinks) Then
        For intIndex = LBound(arLinks) To UBound(arLinks)
            ActiveWorkbook.OpenLinks arLinks(intIndex)
        Next intIndex
    Else
        MsgBox "The active workbook contains no external links."
    End If
End Sub