CustomerData 方法 (PowerPoint)CustomerData.Delete method (PowerPoint)

从**CustomLayoutMasterPresentationShapeSlide** 对象的**CustomerData** 集合中删除指定的**CustomXMLPart** 对象。Deletes the specified CustomXMLPart object from the CustomerData collection of a CustomLayout, Master, Presentation, Shape, or Slide object.


表达式删除( _Id_ )expression.Delete( _Id_ )

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


名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
IdId 必需Required StringString 要删除的CustomXMLPart对象的 ID。The ID of the CustomXMLPart object to be deleted.


CustomerData集合中的单个CustomXMLPart对象由 guid (全局唯一标识符) 表示。Individual CustomXMLPart objects in the CustomerData collection are represented by GUIDs (globally unique identifiers). 通过表示要到 Id 参数的 字符串 形式的 Delete 方法删除的自定义 XML 部件的 GUID。Pass the GUID that represents the custom XML part that you want to delete to the Id parameter of the Delete method as a String. 可以通过循环访问该集合,获得特定的自定义 XML 部件的 ID,使用 Id 属性的 客户 集合。You can get the ID of a particular custom XML part by iterating through the collection, using the Id property of the CustomerData collection.


下面的示例演示如何使用 Delete 方法从CustomerData集合中删除自定义 XML 部件。The following example shows how to use the Delete method to delete a custom XML part from the CustomerData collection. 它将新的自定义 XML 部件添加到活动演示文稿第一张幻灯片上第一个形状的CustomerData集合中。It adds a new custom XML part to the CustomerData collection of the first shape on the first slide of the active presentation. 然后它获取新部件的 ID 并将其传递给的 Delete 方法。Then it gets the ID of the new part and passes it to the Delete method.

Public Sub Delete_Example() 
    Dim pptSlide As Slide 
    Set pptSlide = ActivePresentation.Slides(1) 
    Dim pptShape As Shape 
    Set pptShape = pptSlide.Shapes(1) 
    ' Get the CustomerData collection of the shape 
    Dim pptCustomerData As customerData 
    Set pptCustomerData = pptShape.customerData 
    ' Get the current count of custom XML parts 
    Debug.Print pptCustomerData.Count 
    ' Add a new CustomXMLPart object to the CustomerData 
    ' collection for this shape and get the revised count of 
    ' custom XML parts 
    Dim pptCustomXMLPart As CustomXMLPart 
    Set pptCustomXMLPart = pptCustomerData.Add 
    Debug.Print pptCustomerData.Count 
    ' Get the ID of the new part 
    Dim myString As String 
    myString = pptCustomXMLPart.Id 
    Debug.Print myString 
    ' Delete the new part and re-check the count of custom XML parts 
    pptCustomerData.Delete (myString) 
    Debug.Print pptCustomerData.Count 
End Sub

另请参阅See also

客户集合CustomerData Collection

支持和反馈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.