Share via


DocumentBase.CustomXMLParts Property

Definition

Returns the custom XML parts in the document.

public:
 property Microsoft::Office::Core::CustomXMLParts ^ CustomXMLParts { Microsoft::Office::Core::CustomXMLParts ^ get(); };
public Microsoft.Office.Core.CustomXMLParts CustomXMLParts { get; }
member this.CustomXMLParts : Microsoft.Office.Core.CustomXMLParts
Public ReadOnly Property CustomXMLParts As CustomXMLParts

Property Value

A Microsoft.Office.Core.CustomXMLParts collection that contains the custom XML parts in the document.

Examples

The following code example embeds employee data in the document by adding a Microsoft.Office.Core.CustomXMLPart to the CustomXMLParts collection in the current document. To use this example, run it from the ThisDocument class in a document-level project.

private void AddCustomXmlPartToDocument()
{
    string xmlString =
        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
        "<employees xmlns=\"http://schemas.microsoft.com/vsto/samples\">" +
            "<employee>" +
                "<name>Karina Leal</name>" +
                "<hireDate>1999-04-01</hireDate>" +
                "<title>Manager</title>" +
            "</employee>" +
        "</employees>";

    Office.CustomXMLPart employeeXMLPart = this.CustomXMLParts.Add(xmlString, missing);
}
Private Sub AddCustomXmlPartToDocument()
    Dim xmlString As String = _
        "<?xml version=""1.0"" encoding=""utf-8"" ?>" & _
            "<employees xmlns=""http://schemas.microsoft.com/vsto/samples"">" & _
                "<employee>" & _
                    "<name>Karina Leal</name>" & _
                    "<hireDate>1999-04-01</hireDate>" & _
                    "<title>Manager</title>" & _
                "</employee>" & _
            "</employees>"

    Dim employeeXMLPart As Office.CustomXMLPart = _
        Me.CustomXMLParts.Add(xmlString)
End Sub

Remarks

For more information about using custom XML parts in Office projects, see Custom XML Parts Overview.

Applies to