Workbook.UpdateLink 方法

更新 Microsoft Office Excel、DDE 或 OLE 链接(或多个链接)。

命名空间:  Microsoft.Office.Tools.Excel
程序集:  Microsoft.Office.Tools.Excel(在 Microsoft.Office.Tools.Excel.dll 中)

语法

声明
Sub UpdateLink ( _
    Name As Object, _
    Type As Object _
)
void UpdateLink(
    Object Name,
    Object Type
)

参数

  • Name
    类型:System.Object
    要更新的 Excel 或 DDE/OLE 链接的名称(和从 LinkSources 方法返回的一样)。

备注

如果不使用任何参数调用此方法,则 Excel 默认更新所有工作表链接。

可选参数

有关可选参数的信息,请参见Office 解决方案中的可选参数

示例

下面的代码示例创建到 Excel 工作簿的外部链接,然后使用 UpdateLink 方法更新该链接。 此示例假定工作簿 Book2.xls 存在于 C 盘根目录中。

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
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.");
    }
}

.NET Framework 安全性

请参见

参考

Workbook 接口

Microsoft.Office.Tools.Excel 命名空间