WorkbookBase.ChangeLink Method
Changes a link from one document to another.
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 Sub ChangeLink ( _
name As String, _
newName As String, _
type As XlLinkType _
)
public void ChangeLink(
string name,
string newName,
XlLinkType type
)
Parameters
name
Type: System.StringThe name of the Microsoft Office Excel or DDE/OLE link to be changed, as it was returned from the LinkSources method.
newName
Type: System.StringThe new name of the link.
type
Type: XlLinkTypeOne of the XlLinkType values that specifies the link type.
Remarks
Optional Parameters
For information on optional parameters, see Optional Parameters in Office Solutions.
Examples
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.xlsx and Book3.xls exist at the root of the C directory.
This example is for a document-level customization.
Private Sub ChangeAllLinks()
Globals.Sheet1.Range("A1").FormulaR1C1 = _
"='C:\[Book2.xlsx]Sheet1'!R2C2"
Me.ChangeLink("C:\Book2.xlsx", "C:\Book3.xlsx", _
Excel.XlLinkType.xlLinkTypeExcelLinks)
End Sub
private void ChangeAllLinks()
{
Globals.Sheet1.Range["A1"].FormulaR1C1 =
@"='C:\[Book2.xlsx]Sheet1'!R2C2";
this.ChangeLink(@"C:\Book2.xlsx", @"C:\Book3.xlsx",
Excel.XlLinkType.xlLinkTypeExcelLinks);
}
.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.