Document.FindShapesByTag method (Publisher)
Returns a ShapeRange object that represents the shapes with the specified tag.
Syntax
expression.FindShapesByTag (TagName)
expression A variable that represents a Document object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
TagName | Required | String | The name of the tag. |
Return value
ShapeRange
Example
This example adds two shapes to the first page of the active publication, assigns each a tag, and then enters the name of each tag into the text frame of its assigned shape.
Sub FindShape()
Dim strTag1 As String
Dim strTag2 As String
With ActiveDocument.Pages(1).Shapes
With .AddShape(Type:=msoShape5pointStar, Left:=50, _
Top:=50, Width:=75, Height:=75)
strTag1 = .Tags.Add(Name:="Star", _
Value:="This is a star.").Name
End With
With .AddShape(Type:=msoShapeHeart, Left:=100, _
Top:=100, Width:=75, Height:=75)
strTag2 = .Tags.Add(Name:="Heart", _
Value:="This is a heart.").Name
End With
End With
With ActiveDocument
.FindShapesByTag(TagName:=strTag1).TextFrame _
.TextRange.Text = strTag1
.FindShapesByTag(TagName:=strTag2).TextFrame _
.TextRange.Text = strTag2
End With
End Sub
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.