Freigeben über


WorkbookBase.BreakLink(String, XlLinkType) Method

Definition

Converts formulas linked to other Microsoft Office Excel sources or OLE sources to values.

public:
 void BreakLink(System::String ^ name, Microsoft::Office::Interop::Excel::XlLinkType type);
public void BreakLink (string name, Microsoft.Office.Interop.Excel.XlLinkType type);
member this.BreakLink : string * Microsoft.Office.Interop.Excel.XlLinkType -> unit
Public Sub BreakLink (name As String, type As XlLinkType)

Parameters

name
String

The name of the link.

type
XlLinkType

One of the XlLinkType values. The type of link.

Examples

The following code example creates a link to another Excel workbook and then prompts the user to replace the link with the value of the link destination by using the BreakLink method. This example assumes that workbook Book2.xlsx exists at the root of the C directory.

This example is for a document-level customization.

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

    if (DialogResult.Yes == MessageBox.Show("Break the link?", "Example",
        MessageBoxButtons.YesNo))
    {
        this.BreakLink(@"C:\Book2.xlsx",
            Excel.XlLinkType.xlLinkTypeExcelLinks);
    }
}
Private Sub ConvertLinkToValue()
    Globals.Sheet1.Range("A1").FormulaR1C1 = _
        "='C:\[Book2.xlsx]Sheet1'!R2C2"

    If DialogResult.Yes = MessageBox.Show("Break the link?", _
        "Example", MessageBoxButtons.YesNo) Then
        Me.BreakLink("C:\Book2.xlsx", _
            Excel.XlLinkType.xlLinkTypeExcelLinks)
    End If
End Sub

Applies to