Udostępnij przez


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

Definicja

Pobiera datę łącza i stan aktualizacji.

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

Parametry

name
String

Nazwa łącza.

linkInfoArgument
XlLinkInfo

XlLinkInfo Jedna z wartości określających typ informacji do zwrócenia.

type
Object

XlLinkInfoType Jedna z wartości określających typ linku do zwracania informacji.

editionRef
Object

Jeśli link jest wersją, ten parametr określa odwołanie do edycji jako ciąg w stylu R1C1. EditionRef jest wymagany, jeśli w skoroszycie istnieje więcej niż jeden wydawca lub subskrybent o tej samej nazwie.

Zwraca

Wartość wskazująca informacje o linku. Jeśli LinkInfoArgument jest to xlUpdateState, ta metoda zwraca wartość 1, jeśli link zostanie automatycznie zaktualizowany lub 2, jeśli link musi zostać zaktualizowany ręcznie.

Przykłady

Poniższy przykład kodu używa kolekcji łączy DDE/OLE w bieżącym skoroszycie, a następnie używa LinkInfo metody w celu określenia, czy poszczególne łącza DDE/OLE są aktualizowane automatycznie lub ręcznie.

Ten przykład dotyczy dostosowywania na poziomie dokumentu.

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

Uwagi

Parametry opcjonalne

Aby uzyskać informacje na temat parametrów opcjonalnych, zobacz Parametry opcjonalne w rozwiązaniach pakietu Office.

Dotyczy