WorkbookBase.LinkSources Method
Returns an Array of links in the workbook.
Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)
Syntax
'Declaration
Public Function LinkSources ( _
type As Object _
) As Object
public Object LinkSources(
Object type
)
Parameters
- type
Type: System.Object
One of the XlLink values specifying the type of links to return.
Return Value
Type: System.Object
An Array of link names in the workbook; nulla null reference (Nothing in Visual Basic) if the workbook does not contain any links of the specified Type.
Remarks
The names in the returned Array are the names of the linked documents, editions, or DDE or OLE servers. The format of the array is a one-dimensional array for all types but publisher and subscriber. The returned strings contain the name of the link source, in the appropriate notation for the link type. For example, DDE links use the "Server|Document!Item" syntax.
For publisher and subscriber links, the returned array is two-dimensional. The first column of the array contains the names of the edition, and the second column contains the references of the editions as text.
Optional Parameters
For information on optional parameters, see Optional Parameters in Office Solutions.
Examples
The following code example adds an external Excel link to the current workbook and gets an array of the names of all Excel links in the workbook by using the LinkSources method. The example then uses the OpenLinks method to open each linked workbook as read-only.
This example is for a document-level customization.
Private Sub WorkbookLinkSources()
Globals.Sheet1.Range("A1").Value2 = _
"='C:\[Book2.xls]Sheet1'!R2C2"
Dim links As Array = _
CType(Me.LinkSources(Excel.XlLink.xlExcelLinks), _
Array)
Dim i As Integer
For i = 1 To links.Length
Me.OpenLinks(links(i), True, Excel.XlLink.xlExcelLinks)
Next i
End Sub
private void WorkbookLinkSources()
{
Globals.Sheet1.Range["A1", missing].Value2 =
@"='C:\[Book2.xls]Sheet1'!R2C2";
Array links = (Array)this.LinkSources(Excel.XlLink.xlExcelLinks);
for (int i = 1; i <= links.Length; i++)
{
this.OpenLinks((string)links.GetValue(i), true,
Excel.XlLink.xlExcelLinks);
}
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.