Table of contents
TOC
Collapse the table of content
Expand the table of content

CustomXMLPart.Load Method (Office)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Allows the template author to populate a CustomXMLPart from an existing file. Returns True if the load was successful.

Syntax

expression. Load( FilePath )

expression An expression that returns a CustomXMLPart object.

Parameters

NameRequired/OptionalData TypeDescription
FilePathRequiredStringPoints to the file on the user's computer or on a network containing the XML to be loaded.

Return Value

Boolean

Example

The following example adds a custom XML part, populates the custom XML part with XML from a file, and then manipulates the part's nodes.

Sub ShowCustomXmlParts() 
    On Error GoTo Err 

    Dim cxp1 As CustomXMLPart 

    With ActiveDocument 
        ' Example written for Word. 

        ' Add a custom XML part and then load the XML from a file. 
        Set cxp1 = .CustomXMLParts.Add 
        cxp1.Load "c:\invoice.xml" 

        Set cxn = cxp1.SelectSingleNode("//*[@quantity < 4]")  
        ' Insert a subtree before the single node selected previously. 
        cxn.InsertSubTreeBefore("<discounts><discount>0.10</discount></discounts>")   

        ' Delete custom XML part. 
        cxp1.Delete 
        cxn.Delete 

    End With 

    Exit Sub 

' Exception handling. Show the message and resume. 
Err: 
        MsgBox (Err.Description) 
        Resume Next 
End Sub

See also

Concepts

CustomXMLPart Object

Other resources

CustomXMLPart Object Members

© 2018 Microsoft