Condividi tramite


WorkbookBase.LinkInfo(String, XlLinkInfo, Object, Object) Metodo

Definizione

Ottiene la data di collegamento e lo stato di aggiornamento.

public object LinkInfo (string name, Microsoft.Office.Interop.Excel.XlLinkInfo linkInfoArgument, object type, object editionRef);
member this.LinkInfo : string * Microsoft.Office.Interop.Excel.XlLinkInfo * obj * obj -> obj
Public Function LinkInfo (name As String, linkInfoArgument As XlLinkInfo, Optional type As Object, Optional editionRef As Object) As Object

Parametri

name
String

Nome del collegamento.

linkInfoArgument
XlLinkInfo

Uno dei valori di XlLinkInfo che specifica il tipo di informazioni da restituire.

type
Object

Uno dei valori di XlLinkInfoType che specifica il tipo di collegamento per il quale restituire informazioni.

editionRef
Object

Se il collegamento è una versione, questo parametro specifica il riferimento alla versione sotto forma di stringa nella notazione R1C1. EditionRef è obbligatorio se nella cartella di lavoro sono presenti più server di pubblicazione o sottoscrittori con lo stesso nome.

Restituisce

Valore che indica informazioni relative al collegamento. Se l'argomento LinkInfoArgument è impostato su xlUpdateState, questo metodo restituisce il valore 1 se il collegamento viene aggiornato automaticamente oppure il valore 2 se il collegamento viene aggiornato manualmente.

Esempio

Nell'esempio di codice seguente viene utilizzata la raccolta di collegamenti DDE/OLE nella cartella di lavoro corrente e quindi viene utilizzato il LinkInfo metodo per determinare se ogni collegamento DDE/OLE viene aggiornato automaticamente o manualmente.

Questo esempio è relativo a una personalizzazione a livello di documento.

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

Commenti

Parametri facoltativi

Per informazioni sui parametri facoltativi, vedere parametri facoltativi nelle soluzioni Office.

Si applica a