CustomXMLPart 方法 (Office)CustomXMLPart.Delete method (Office)

从数据存储(IXMLDataStore 接口)中删除当前 CustomXMLPartDeletes the current CustomXMLPart from the data store (IXMLDataStore interface).

语法Syntax

表达式删除expression.Delete

_表达式_一个返回**CustomXMLPart** 对象的表达式。expression An expression that returns a CustomXMLPart object.

说明Remarks

如果尝试删除包含核心属性的部件,则不会执行操作并显示一条错误消息。If you attempt to delete the part containing the core properties, the operation is not performed and an error message is displayed.

示例Example

下面的示例添加一个自定义 XML 部件, 选择具有条件的节点, 然后删除该部件和节点。The following example adds a custom XML part, selects a node with a criteria, and deletes the part and node.

Sub ShowCustomXmlParts() 
    On Error GoTo Err 
 
    Dim cxp1 As CustomXMLPart 
    Dim cxn As CustomXMLNode 
 
    With ActiveDocument 
        ' Example written for Word. 
 
        ' Add and then load 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

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.