Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop through shapes in Visio

Status
Not open for further replies.

Wei1991

Technical User
May 25, 2012
2
US
I am trying to compare elements of the shapes via double for loop when I find the property I wanted I had to add in a connector shape but then it messes up the shape count.

My code looks like the following:

For intCount = 1 To pagThisPage.Shapes.Count - 1
Set shape1 = pagThisPage.Shapes.Item(intCount)
For intCount2 = intCount + 1 To pagThisPage.Shapes.Count
Set shape2 = pagThisPage.Shapes.Item(intCount2)
If shape1.Cells("Prop.StepNumber").ResultInt(visNumber, 0) =
shape2.Cells("Prop.StepNumber").ResultInt(visNumber, 0) Then
'if property equal drop a connection between the two entries
Set shpConnector = pagThisPage.Drop(mstConnector, 0#, 0#)

What can I do to prevent adding in new shapes interfering with reading the shapes already there?
 


Hi,

Try something like this. Adding shapes will NOT affect the loop...
Code:
dim shp1 as shape

for each shp1 in  pagThisPage.Shapes
   debug.print shp1.name
next
use this For Each...Next loop for your outer loop. Does not matter if the inner loop used an index and if it includes added shapes, does it?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top