Workbook.LinkInfo Method (2007 System)

Gets the link date and update status.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

Syntax

'Declaration
Public Function LinkInfo ( _
    Name As String, _
    LinkInfoArgument As XlLinkInfo, _
    Type As Object, _
    EditionRef As Object _
) As Object
'Usage
Dim instance As Workbook 
Dim Name As String 
Dim LinkInfoArgument As XlLinkInfo 
Dim Type As Object 
Dim EditionRef As Object 
Dim returnValue As Object 

returnValue = instance.LinkInfo(Name, _
    LinkInfoArgument, Type, EditionRef)
public Object LinkInfo(
    string Name,
    XlLinkInfo LinkInfoArgument,
    Object Type,
    Object EditionRef
)
public:
Object^ LinkInfo(
    String^ Name, 
    XlLinkInfo LinkInfoArgument, 
    Object^ Type, 
    Object^ EditionRef
)
public function LinkInfo(
    Name : String, 
    LinkInfoArgument : XlLinkInfo, 
    Type : Object, 
    EditionRef : Object
) : Object

Parameters

  • LinkInfoArgument
    Type: XlLinkInfo

    One of the XlLinkInfo values that specifies the type of information to return.

  • EditionRef
    Type: System.Object

    If the link is an edition, this parameter specifies the edition reference as a string in R1C1 style. EditionRef is required if there is more than one publisher or subscriber with the same name in the workbook.

Return Value

Type: System.Object
A value that indicates information about the link. If LinkInfoArgument is xlUpdateState, this method returns 1 if the link updates automatically, or 2 if the link must be updated manually.

Remarks

Optional Parameters

For information on optional parameters, see The Variable missing and Optional Parameters in Office Solutions.

Examples

The following code example uses gets the collection of DDE/OLE links in the current workbook, and then uses the LinkInfo method to determine whether or not each DDE/OLE link updates automatically or manually.

This example is for a document-level customization.

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,
                missing);

            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 Security

See Also

Reference

Workbook Class

Workbook Members

Microsoft.Office.Tools.Excel Namespace