Table of contents
Collapse the table of content
Expand the table of content

Document.FindShapesByTag Method (Publisher)

office 365 dev account|Last Updated: 8/24/2017
3 Contributors

Returns a ShapeRange object that represents the shapes with the specified tag.


expression. FindShapesByTag( TagName)

_expression_A variable that represents a Document object.


NameRequired/OptionalData TypeDescription
TagNameRequiredStringThe name of the tag.

Return Value



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
© 2018 Microsoft