CustomerData 对象 (PowerPoint)CustomerData object (PowerPoint)

将有关客户的信息 (如姓名、地址、电话号码等) 或 XML 表单中的其他信息存储为与 Microsoft PowerPoint 对象关联的**CustomXMLPart** 对象的集合。Stores information about a customer (such as name, address, telephone number, and so on) or other information in XML form, as a collection of CustomXMLPart objects associated with a Microsoft PowerPoint object.

说明Remarks

您可以将客户数据存储在**CustomLayoutMasterPresentationShapeSlide** 对象中。You can store customer data in CustomLayout, Master, Presentation, Shape, and Slide objects. 可以将一个或多个 CustomXMLPart 对象具有相同的对象相关联。You can associate one or more CustomXMLPart objects with the same object.

  • 只有在将 PowerPoint 文档以 XML 文件格式存储为 PowerPoint XML 演示文稿的情况下,一个实例中的客户数据才可以保留在该文档的下一个实例中。Customer data persists from one instance to the next in a PowerPoint document only when you save the document in XML file format, as a PowerPoint XML presentation. 客户数据不会保留在以 .ppt, .htm 或 .mht 格式保存的文档中。Customer data does not persist in documents saved in .ppt, .htm, or .mht formats.

  • PowerPoint 中没有与客户数据相关的用户界面。There is no user interface associated with customer data in PowerPoint. 分配和操作客户数据的唯一方法是通过编程来实现。The only way that you can assign and manipulate customer data is programmatically.

使用**add** 方法可将新的CustomXMLPart对象添加到CustomerData集合中。Use the Add method to add a new CustomXMLPart object to the CustomerData collection.

使用**delete** 方法可从CustomerData集合中删除一个CustomXMLPart对象。Use the Delete method to delete a CustomXMLPart object from the CustomerData collection.

使用**Item** 方法可从集合中获取特定的CustomXMLPart对象。Use the Item method to get a specific CustomXMLPart object from the collection. 由 Guid (全局唯一标识符) 表示集合中的单个项。Individual items in the collection are represented by GUIDs (globally unique identifiers).

您可以像在 Microsoft Office PowerPoint 2007 以前的版本中使用**标签** 对象一样使用客户数据, 也就是说, 将数据与对象相关联。You can use customer data in the same way that you used Tags objects in versions of PowerPoint previous to Microsoft Office PowerPoint 2007--that is, to associate data with objects. 不过,由于客户数据存储为 XML 而不是简单的字符串,客户数据比标记的功能更强大。Customer data is more powerful than tags, however, because you can store the data as XML instead of as a simple string.

可以通过在电子表格或数据库中将自定义 XML 部件的 ID 与外部数据存储在一起,将 PowerPoint 中的客户数据与外部数据相关联。You can associate customer data in PowerPoint with external data by storing the IDs of custom XML parts in a spreadsheet or database along with the external data.

当您复制一个对象,包含客户数据时,客户数据被复制到新对象。When you copy an object that contains customer data, the customer data is copied to the new object. PowerPoint 将创建一个新的CustomXMLPart对象来保存复制的数据, 因为两个CustomLayoutMasterPresentationShapeSlide对象永远不能与同一个 CustomXMLPart 相关联。 **** 对象。PowerPoint creates a new CustomXMLPart object to hold the copied data, because two CustomLayout, Master, Presentation, Shape, or Slide objects can never be associated with the same CustomXMLPart object.

示例Example

下面的示例演示如何向活动演示文稿第一张幻灯片上的第一个形状的CustomerData集合中添加一个CustomXMLPart对象, 以及如何将 XML 字符串加载到自定义 XML 部件中。The following example shows how to add a CustomXMLPart object to the CustomerData collection of the first shape on the first slide of the active presentation, and how to load an XML string into the custom XML part. 它输出的自定义 XML 部件,并在立即窗口中的 XML 字符串的 ID。It prints the ID of the custom XML part and the XML string in the Immediate window.

Public Sub CustomerData_Example() 
 
    Dim pptCustomXMLPart As CustomXMLPart 
     
    Set pptCustomXMLPart = ActivePresentation.Slides(1).Shapes(1).customerData.Add 
     
    Debug.Print pptCustomXMLPart.Id 
     
    pptCustomXMLPart.LoadXML ("<Customer><CustomerID>Customer #1</CustomerID></Customer>") 
     
    Debug.Print pptCustomXMLPart.xml 
 
End Sub

另请参阅See also

PowerPoint 对象模型引用PowerPoint Object Model Reference

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