共用方式為


(Office) 的 CustomXMLPart.Delete 方法

IXMLDataStore介面) (資料存放區中刪除目前的CustomXMLPart

語法

運算式刪除

表達 會傳回 CustomXMLPart 物件的運算式。

註解

如果您嘗試刪除含有核心屬性的組件,則不會執行操作,並且會顯示錯誤訊息。

範例

下列範例會新增自訂 XML 元件、選取具有準則的節點,以及刪除元件和節點。

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

另請參閱

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應