Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

CustomXMLParts.Add Method

Office 2007
Allows you to add a new CustomXMLPart to a file.
Aa433523.vs_note(en-us,office.12).gif  Note
References to DTDs from custom XML parts are not supported. DTD references in custom XML parts will not resolve, and custom XML parts containing DTD references generate an exception when an attempt is made to save the file's content to a flat XML file.

Syntax

expression.Add(XML, SchemaCollection)

expression   An expression that returns a CustomXMLParts object.

Parameters

NameRequired/OptionalData TypeDescription
XMLOptionalStringContains the XML to add to the newly created CustomXMLPart.
SchemaCollectionOptionalCustomXMLSchemaCollectionRepresents the set of schemas to be used to validate this stream.

Return Value
CustomXMLPart

Example
The following example adds a new CustomXMLPart, selects a CustomXMLPart using a search criteria, and then selects a single node from that part.

Visual Basic for Applications
Sub ShowCustomXmlParts()
    On Error GoTo Err

    Dim cxp1 As CustomXMLPart

    Dim cxn As CustomXMLNode
    Dim cxns As CustomXMLNodes
    Dim strXml As String
    Dim strUri As String

        ' Example written for Word.

        ' Add a custom XML part.
        ActiveDocument.CustomXMLParts.Add "<custXMLPart />"

        ' Returns the first custom XML part with the given root namespace.
        Set cxp1 = ActiveDocument.CustomXMLParts("urn:invoice:namespace")        

        ' Get a node using XPath.                             
        Set cxn = cxp1.SelectSingleNode("//*[@quantity < 4]") 
    
    Exit Sub
                
' Exception handling. Show the message and resume.
Err:
        MsgBox (Err.Description)
        Resume Next
End Sub



Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.