CustomXMLPart.Load 方法 (Office)

使模板作者可以通过现有文件填充 CustomXMLPart。 如果加载成功,则返回 True

语法

表达式加载 (FilePath)

表达 返回 CustomXMLPart 对象的表达式。

参数

名称 必需/可选 数据类型 说明
FilePath 必需 字符串 指向用户计算机或包含要加载的 XML 的网络上的文件。

返回值

布尔值

示例

以下示例将添加一个自定义 XML 部件、使用一个文件中的 XML 填充该自定义 XML 部件,然后处理部件的节点。

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

另请参阅

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。