Share via


Tags Object

Publisher Developer Reference

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

Example

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.

Visual Basic for Applications
  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.

Visual Basic for Applications
  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

See Also