Sdílet prostřednictvím


WorkbookBase.OpenLinks(String, Object, Object) Method

Definition

Opens the supporting documents for a link or links.

public void OpenLinks (string name, object readOnly, object type);
member this.OpenLinks : string * obj * obj -> unit
Public Sub OpenLinks (name As String, Optional readOnly As Object, Optional type As Object)

Parameters

name
String

The name of the Microsoft Office Excel or DDE/OLE link, as returned from the LinkSources(Object) method.

readOnly
Object

true to open documents as read-only. The default value is false.

type
Object

One of the XlLink values. The link type.

Examples

The following code example uses the LinkSources method to get an array of the names of all Excel links in the current workbook. The example then uses the OpenLinks method to open each document as read-only.

This example is for a document-level customization.

private void WorkbookLinkSources()
{
    Globals.Sheet1.Range["A1"].Value2 =
        @"='C:\[Book2.xlsx]Sheet1'!R2C2";
    Array links = (Array)this.LinkSources(Excel.XlLink.xlExcelLinks);

    for (int i = 1; i <= links.Length; i++)
    {
        this.OpenLinks((string)links.GetValue(i), true,
            Excel.XlLink.xlExcelLinks);
    }
}
Private Sub WorkbookLinkSources()
    Globals.Sheet1.Range("A1").Value2 = _
        "='C:\[Book2.xlsx]Sheet1'!R2C2"
    Dim links As Array = _
        CType(Me.LinkSources(Excel.XlLink.xlExcelLinks),  _
        Array)

    Dim i As Integer
    For i = 1 To links.Length
        Me.OpenLinks(links(i), True, Excel.XlLink.xlExcelLinks)
    Next i
End Sub

Remarks

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Applies to