Tags 对象 (PowerPoint)Tags object (PowerPoint)

代表可为形状、幻灯片或演示文稿创建的标记或自定义属性。Represents a tag or a custom property that you can create for a shape, slide, or presentation.


每个Tags对象包含自定义属性的名称和该属性的值。Each Tags object contains the name of a custom property and a value for that property.

如果要对集合的指定成员进行选择性操作,请基于非内置的属性创建标记。Create tags when you want to be able to selectively work with specific members of a collection, based on an attribute that isn't already represented by a built-in property. 例如,如果要根据所应用的国家/地区中来分类演示文稿中的幻灯片,可以创建地区标记并为每个幻灯片的地区标记赋值。For example, if you want to be able to categorize slides in a presentation based on what region of the country/region they apply to, you could create a Region tag and assign a Region value to each slide in the presentation. 然后,可以根据地区标记值对某些幻灯片进行选择性操作,例如将地区标记值为“East”的所有幻灯片隐藏。You could then selectively perform an operation on some of the slides, based on the values of their Region tags, such as hiding all the slides with the Region value "East."


使用add方法可向对象添加标记。Use the Add method to add a tag to an object. 下面的示例在当前演示文稿中添加标记与"区域"的名称和值"东部"第一张幻灯片。The following example adds a tag with the name "Region" and with the value "East" to slide one in the active presentation.

ActivePresentation.Slides(1).Tags.Add "Region", "East"

使用标记(索引), 其中_索引_是标记的名称, 以返回标记值。Use Tags (index), where index is the name of a tag, to return a the tag value. 下面的示例测试活动演示文稿中所有幻灯片的地区标记值,并隐藏所有不属于东海岸 (由"East"值表示) 的幻灯片。The following example tests the value of the Region tag for all slides in the active presentation and hides any slides that don't pertain to the East Coast (denoted by the value "East").

For Each s In ActivePresentation.Slides

    If s.Tags("region") <> "east" Then

        s.SlideShowTransition.Hidden = True

    End If


另请参阅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.