Export (0) Print
Expand All
Expand Minimize

Workbook.ChangeLink Method

Changes a link from one document to another.

Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in microsoft.office.tools.excel.dll)

public virtual void ChangeLink (
	string Name,
	string NewName,
	[OptionalAttribute] XlLinkType Type
)

Parameters

Name

The name of the Microsoft Office Excel or DDE/OLE link to be changed, as it was returned from the LinkSources method.

NewName

The new name of the link.

Type

One of the XlLinkType values that specifies the link type.

Optional Parameters

For information on optional parameters, see Understanding Optional Parameters in COM Interop.

The following code example creates an external link to an Excel workbook and then uses the ChangeLink method to change the link destination. This example assumes that workbooks Book2.xls and Book3.xls exist at the root of the C directory.

private void ChangeAllLinks()
{
    Globals.Sheet1.Range["A1", missing].FormulaR1C1 =
        @"='C:\[Book2.xls]Sheet1'!R2C2";

    this.ChangeLink(@"C:\Book2.xls", @"C:\Book3.xls",
        Excel.XlLinkType.xlLinkTypeExcelLinks);
}

Show:
© 2014 Microsoft