CustomXMLPart.LoadXML 方法 (Office)
允许模板作者依据 XML 字符串填充 CustomXMLPart 对象。 如果加载成功,则返回 True。
语法
表达式。LoadXML (XML)
表达 返回 CustomXMLPart 对象的表达式。
参数
名称 | 必需/可选 | 数据类型 | 说明 |
---|---|---|---|
XML | 必需 | 字符串 | 包含要加载的 XML。 |
返回值
布尔值
示例
以下示例通过字符串将 XML 加载到自定义 XML 部件中。
Sub ShowCustomXmlParts()
On Error GoTo Err
Dim cxp1 As CustomXMLPart
' Add a custom XML part and then load the XML.
Set cxp1 = ActiveDocument.CustomXMLParts.Add
cxp1.LoadXML("<discounts><discount>0.10</discount></discounts>")
Exit Sub
' Exception handling. Show the message and resume.
Err:
MsgBox (Err.Description)
Resume Next
End Sub
另请参阅
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。