WorkbookBase.LinkInfo (Método)

Obtiene la fecha del vínculo y el estado de actualización.

Espacio de nombres:  Microsoft.Office.Tools.Excel
Ensamblado:  Microsoft.Office.Tools.Excel.v4.0.Utilities (en Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

Sintaxis

'Declaración
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
)

Parámetros

  • editionRef
    Tipo: System.Object
    Si el vínculo es una edición, este parámetro especifica la referencia de edición como una cadena en estilo R1C1.Se requiere EditionRef si hay más de un publicador o suscriptor con el mismo nombre en el libro.

Valor devuelto

Tipo: System.Object
Valor que indica información sobre el vínculo.Si LinkInfoArgument es xlUpdateState, este método devuelve 1 si el vínculo se actualiza automáticamente o 2 si se debe actualizar manualmente.

Comentarios

Parámetros opcionales

Para obtener información sobre parámetros opcionales, vea Parámetros opcionales en las soluciones de Office.

Ejemplos

El ejemplo de código siguientes usa Get para obtener la colección de vínculos DDE/OLE del libro actual y, a continuación, usa el método LinkInfo para determinar si los vínculos DDE/OLE se actualizan automática o manualmente.

Se trata de un ejemplo para una personalización en el nivel del documento.

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

Seguridad de .NET Framework

Vea también

Referencia

WorkbookBase Clase

Microsoft.Office.Tools.Excel (Espacio de nombres)