Tags - Store information associative with a presentation, slide or shape

PowerPoint object model defines Tags collection for presentations, slides within a presentation and shapes on a slide. The Tags collection is available through the Tags property of the Presentation, Slide and Shape objects. A tag consists of a name and a value associated with that name. Name is always in UPPERCASE (if you give it in lowercase, PowerPoint will convert it to uppercase). Value can be in any case. Name is always unique within a particular Tags collection. The following code snippets show how to manage Tags collection:

Add a tag to the active presentation:

ActivePresentation.Tags.Add "TAG_NAME", "Tag_Value"

Retrieve tag value using its name:

ActivePresentation.Tags("TAG_NAME")

Iterate over all tags in the active presentation:

Sub Iterate()
    Dim I As Long
    Dim S As String

    With ActivePresentation
        For I = 1 To .Tags.Count
            S = S + CStr(I) + ": Name = " + .Tags.Name(I) + _
                ", Value = " + .Tags.Value(I)
        Next
        MsgBox S
    End With
End Sub

Contact OfficeOne on email at officeone@officeoneonline.com. Copyright © 2001-2023 OfficeOne. All rights reserved.