NamedRange.XPath Property

Definition

Gets an XPath that represents the Xpath of the element mapped to the NamedRange control.

public:
 property Microsoft::Office::Interop::Excel::XPath ^ XPath { Microsoft::Office::Interop::Excel::XPath ^ get(); };
public Microsoft.Office.Interop.Excel.XPath XPath { get; }
member this.XPath : Microsoft.Office.Interop.Excel.XPath
Public ReadOnly Property XPath As XPath

Property Value

An XPath that represents the Xpath of the element mapped to the NamedRange control.

Examples

The following code example maps an XmlMap to the current workbook, and then sets the XPath property of a NamedRange to an XPath defined in the XmlMap. This example assumes that an Excel Schema Definition file named Customers.xsd that contains the XPath definition "/ns1:Customer/ns1:LastName" exists at the root of the C directory.

This example is for a document-level customization.

private void UseXPath()
{
    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A1"],
        "namedRange1");

    Excel.XmlMap xmlMap1 = Globals.ThisWorkbook.XmlMaps.Add(
        @"C:\Customers.xsd", "Customer");

    namedRange1.XPath.SetValue(xmlMap1,
        "/ns1:Customer/ns1:LastName", false);

    MessageBox.Show("The XPath of the NamedRange is: " +
        namedRange1.XPath.Value);
}
Private Sub UseXPath()
    Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
        = Me.Controls.AddNamedRange(Me.Range("A1"), _
        "namedRange1")

    Dim xmlMap1 As Excel.XmlMap = _
        Globals.ThisWorkbook.XmlMaps.Add("C:\Customers.xsd", _
        "Customer")

    namedRange1.XPath.SetValue(xmlMap1, _
        "/ns1:Customer/ns1:LastName", , False)

    MessageBox.Show("The XPath of the NamedRange is: " & _
        namedRange1.XPath.Value)
End Sub

Remarks

XML features, except for saving files in the XML Spreadsheet format, are available only in Microsoft Office Professional Edition 2003 and Microsoft Office Excel 2003.

Applies to