Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Tags Collection

Tags Collection


This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Aa662088.parchild(en-us,office.10).gifTags
Aa662088.space(en-us,office.10).gifAa662088.parchild(en-us,office.10).gifTag

A collection of Tag objects that represents tags or custom properties applied to a shape, shape range, page, or publication.

Using the Tags Object

Use the Tags property to access the Tags collection. Use the Add method of the Tags collection to add a Tag object to a shape, shape range, page, or publication. This example adds a tag to each oval shape on the first page of the active publication.

Sub AddNewTag()
    Dim shp As Shape
    With ActiveDocument.Pages(1)
        For Each shp In .Shapes
            If InStr(1, shp.Name, "Oval") > 0 Then
                shp.Tags.Add Name:="Shape", Value:="Oval"
            End If
        Next shp
    End With
End Sub

Use the Count property to determine if a shape, shape range, page, or publication contains one or more Tag objects. This example fills all shapes on the first page of the active publication if the shape's first tag has a value of Oval.

Sub FormatTaggedShapes()
    Dim shp As Shape
    With ActiveDocument.Pages(1)
        For Each shp In .Shapes
            If shp.Tags.Count > 0 Then
                If shp.Tags(1).Value = "Oval" Then
                    shp.Fill.ForeColor.RGB = RGB(Red:=255, Green:=0, Blue:=0)
                End If
            End If
        Next shp
    End With
End Sub
Show:
© 2015 Microsoft