Workbook.CustomXMLParts Property (2007 System)
Gets the collection of custom XML parts in the workbook.
Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)
Syntax
'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property CustomXMLParts As CustomXMLParts
'Usage
Dim instance As Workbook
Dim value As CustomXMLParts
value = instance.CustomXMLParts
[BrowsableAttribute(false)]
public CustomXMLParts CustomXMLParts { get; }
[BrowsableAttribute(false)]
public:
property CustomXMLParts^ CustomXMLParts {
CustomXMLParts^ get ();
}
public function get CustomXMLParts () : CustomXMLParts
Property Value
Type: CustomXMLParts
A Microsoft.Office.Core.CustomXMLParts collection that contains the custom XML parts in the workbook.
Remarks
For more information about custom XML parts, see Custom XML Parts Overview.
Examples
The following code example adds employee data to the document by inserting a new Microsoft.Office.Core.CustomXMLPart in the Microsoft.Office.Core.CustomXMLParts collection. The example then retrieves employee data from the XML part and displays the employee name and hire date on Sheet1.
This example is for a document-level customization.
Private Sub AddCustomXMLPart()
Dim xmlString As String = _
"<?xml version=""1.0"" encoding=""utf-8"" ?>" _
+ "<employees>" _
+ "<employee>" _
+ "<name>Karina Leal</name>" _
+ "<hireDate>1999-04-01</hireDate>" _
+ "</employee>" _
+ "</employees>"
Dim employeeXMLPart As Office.CustomXMLPart = _
Me.CustomXMLParts.Add(xmlString)
Globals.Sheet1.Range("A1").Value2 = employeeXMLPart.SelectSingleNode( _
"/employees[1]/employee[1]/name[1]").Text
Globals.Sheet1.Range("A2").Value2 = employeeXMLPart.SelectSingleNode( _
"/employees[1]/employee[1]/hireDate[1]").Text
End Sub
private void AddCustomXMLPart()
{
string xmlString =
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
+ "<employees>"
+ "<employee>"
+ "<name>Karina Leal</name>"
+ "<hireDate>1999-04-01</hireDate>"
+ "</employee>"
+ "</employees>";
Office.CustomXMLPart employeeXMLPart =
this.CustomXMLParts.Add(xmlString,missing);
Globals.Sheet1.Range["A1",missing].Value2 = employeeXMLPart.SelectSingleNode(
"/employees[1]/employee[1]/name[1]").Text;
Globals.Sheet1.Range["A2",missing].Value2 = employeeXMLPart.SelectSingleNode(
"/employees[1]/employee[1]/hireDate[1]").Text;
}
.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.