Find shapes

M

mi00mf

Hallo at all,
Is there a method or command in Visio 2003 Automation VBA Language that
returns all shapes (a shapes' collection) containing a certain text that I
would to retrieve ?
I would to reproduce the Find window operation in programming code.

Thanks to all for your attention
 
M

Markus Breugst

Hello,

I've written a small macro for you. It selects all shapes within the active
page that have a specific text.
Hope that gives you an idea of how to solve such a problem.

Best regards,
Markus

Public Sub DoIt()
findShapes ("theTextToSearchFor")
End Sub

Public Sub findShapes(searchString As String)
Dim result As Shapes
Dim shapeIndex As Integer
Dim theShape As Shape

ActiveWindow.DeselectAll
For shapeIndex = 1 To ActiveWindow.Page.Shapes.Count
Set theShape = ActiveWindow.Page.Shapes(shapeIndex)
If theShape.Text = searchString Then
ActiveWindow.Select theShape, visSelect
End If
Next shapeIndex
End Sub
 
M

mi00mf

Thanks a lot for Your immediate answer,
but I would to know if exists in VBA Visio a method as the
Selection.Find method in Word or Excel to extract in only one instruction a
shapes collection satisfying one research condition.

Thanks to all for Your attention
 
M

Mark Nelson [MS]

There is no such method, so Markus' code is the best way to programmatically
find the shapes.
 
M

mi00mf

Ok, Thanks a lot

Mark Nelson said:
There is no such method, so Markus' code is the best way to programmatically
find the shapes.

--
Mark Nelson
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top