次の方法で共有


Workbook.UpdateLink(Object, Object) Method

Definition

Updates a Microsoft Office Excel, DDE, or OLE link (or links).

public void UpdateLink (object Name, object Type);
abstract member UpdateLink : obj * obj -> unit
Public Sub UpdateLink (Optional Name As Object, Optional Type As Object)

Parameters

Name
Object

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

Type
Object

One of the XlLinkType values.

Examples

The following code example creates an external link to an Excel workbook and then uses the UpdateLink method to update the link. This example assumes that workbook Book2.xlsx exists at the root of the C directory.

private void WorkbookUpdateLink()
{
    Array links = (Array)this.LinkSources(Excel.XlLink.xlExcelLinks);

    if (links != null)
    {
        for (int i = 1; i <= links.Length; i++)
        {
            this.UpdateLink((string)links.GetValue(i),
                Excel.XlLinkType.xlLinkTypeExcelLinks);
        }
    }
    else
    {
        MessageBox.Show("The workbook contains no links to " +
            "other workbooks.");
    }
}
Private Sub WorkbookUpdateLink()
    Dim Links As Array = _
        CType(Me.LinkSources(Excel.XlLink.xlExcelLinks),  _
        Array)
    If Links IsNot Nothing Then
        Dim i As Integer
        For i = 1 To Links.Length
            Me.UpdateLink(Links(i), _
                Excel.XlLinkType.xlLinkTypeExcelLinks)
        Next i
    Else
        MsgBox("The workbook contains no links to " & _
            "other workbooks.")
    End If
End Sub

Remarks

When this method is called without any parameters, Excel defaults to updating all worksheet links.

Optional Parameters

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

Applies to