從資料存放區 (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 支援與意見反應。