다음을 통해 공유


WorkbookBase.BreakLink Method

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

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 BreakLink ( _
    name As String, _
    type As XlLinkType _
)
public void BreakLink(
    string name,
    XlLinkType type
)

Parameters

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 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
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);
    }
}

.NET Framework Security

See Also

Reference

WorkbookBase Class

Microsoft.Office.Tools.Excel Namespace