WorkbookBase.LinkInfo 方法

命名空間:  Microsoft.Office.Tools.Excel
組件:  Microsoft.Office.Tools.Excel.v4.0.Utilities (在 Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 中)

語法

'宣告
Public Function LinkInfo ( _
    name As String, _
    linkInfoArgument As XlLinkInfo, _
    type As Object, _
    editionRef As Object _
) As Object
public Object LinkInfo(
    string name,
    XlLinkInfo linkInfoArgument,
    Object type,
    Object editionRef
)

參數

  • editionRef
    型別:System.Object
    如果連結含有版本資訊,此參數將版本參照指定為 R1C1 樣式的字串。如果活頁簿中有一個以上的發行者或訂閱者具有相同名稱,則需要 EditionRef。

傳回值

型別:System.Object
表示連結相關資訊的值。當 LinkInfoArgument 是 xlUpdateState 時,如果連結會自動更新則此方法傳回 1,如果連結必須手動更新則傳回 2。

備註

選擇性參數

如需選擇性參數的詳細資訊,請參閱Office 方案中的選擇性參數

範例

下列程式碼範例取得目前活頁簿的 DDE/OLE 連結集合,然後使用 LinkInfo 方法,判斷是否要自動或手動更新每個 DDE/OLE 連結。

這是示範文件層級自訂的範例。

Private Sub WorkbookLinkInfo()
    ' Get the collection of DDE/OLE links in the workbook.
    Dim Links As Array = _
        CType(Me.LinkSources(Excel.XlLink.xlOLELinks),  _
        Array)

    ' If there are DDE/OLE links, then display how each link
    ' updates.
    If Links IsNot Nothing Then
        Dim i As Integer
        For i = 1 To Links.Length
            Dim UpdateValue As Integer = Me.LinkInfo(Links(i), _
                Excel.XlLinkInfo.xlUpdateState, _
                Excel.XlLinkInfoType.xlLinkInfoOLELinks)

            If UpdateValue = 1 Then
                MsgBox(Links(i) & " link updates automatically.")
            ElseIf UpdateValue = 2 Then
                MsgBox(Links(i) & " link updates manually.")
            End If
        Next i
    Else
        MsgBox("The workbook contains no DDE/OLE links.")
    End If
End Sub
private void WorkbookLinkInfo()
{
    // Get the collection of DDE/OLE links in the workbook.
    Array links = (Array)this.LinkSources(Excel.XlLink.xlOLELinks);

    // If there are DDE/OLE links, then display how each link
    // updates.
    if (links != null)
    {
        for (int i = 1; i <= links.Length; i++)
        {
            string linkName = (string)links.GetValue(i);
            int updateValue = (int)this.LinkInfo(linkName,
                Excel.XlLinkInfo.xlUpdateState,
                Excel.XlLinkInfoType.xlLinkInfoOLELinks);

            if (updateValue == 1)
            {
                MessageBox.Show(linkName + " link updates automatically.");
            }
            else if (updateValue == 2)
            {
                MessageBox.Show(linkName + " link updates manually.");
            }
        }
    }
    else
    {
        MessageBox.Show("The workbook contains no DDE/OLE links.");
    }
}

.NET Framework 安全性

請參閱

參考

WorkbookBase 類別

Microsoft.Office.Tools.Excel 命名空間