getting accurate shape count

A

Arash Ferdowsi

Hi,
I'm writing a VBA macro and am running into problems with shape counts. My
macro runs through all shapes on each page and performs a series of actions
on each shape. My problem arose because I've deleted/added shapes several
times and thus on most pages of my document, shape.count returns a number
much less than the highest shape ID. Is there any way to get the largest
shape ID on a page or a different work around? Also, I need to change the
active window to a different document, how can this be done? Thanks in
advance.
 
M

Mark Nelson [MS]

What are you trying to do with the count? If you are iterating through all
the shapes on the page then you should use the range 1 to Shapes.Count.
These are Index values for each of the shapes, and Visio maintains a
contiguous set.

Shape ID is more like a counter. The set of IDs for a page is not
guaranteed to be contiguous, so you should not use this to iterate through
your shapes.
 
A

Arash Ferdowsi

Thanks a lot, that's what I need, except I'm still not sure how to access the
shape by ShapeID. I get an error when I use this:

ActiveWindow.Select
Application.ActiveWindow.Page.Shapes.ShapeID(intCounter), visSelect

Will ActiveWindow.Select
Application.ActiveWindow.Page.Shapes.Item(intCounter), visSelect do the job?
Thanks a lot.
 
M

Mark Nelson [MS]

Use the Item method.

--
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