Access shapes by physical location on the drawing

B

ben h

I have a diagram with a series of shapes stacked "vertically" down the
window (in the sense of a user looking at a printed page, the shapes are
vertically stacked). They are text boxes with some text like "#. foo
bar". I want to write a macro that cycles through each of these shapes,
and changes the "#" to an ordered sequence, top to bottom. Like so:

-----------------
| |
| 1. My foo bar |
| |
-----------------
-----------------
| |
| 2. his foo bar |
| |
-----------------
-----------------
| |
| 3. her foo bar |
| |
-----------------

They are all from the same Master.

They will either have a one or two digit number followed by a period
('.'), OR they will have a pound symbol ('#') followed by a period.

Can anyone spot me a starter?

Ben
 
J

John Marshall, MVP

Is there more than one stack?

Two ways:
1) Assign an imaginary grid to the page and then cycle through the points.
Start at the top of the first column and go down. For each point use one of
Visio's spatial relation functions to determine if a shape is near that
point. Once a shape is found, assign it a value of one and then go to the
point below. Is there a shape there? then assign it 2. etc.

2) Cycle through the shapes and only select shapes with that master. Create
an array of the masters with the x,y position and the shape name. Sort the
array. Loop through the array and select each shape by the master name and
then assign the numbers. Just in case the shapes have not been vertically
aligned, store a rounded value of the x position. (The x positions could be
4.44, 4.51, 4.6 and 4.49 round them all to 4.5) The y position should be
from the top of the page so that the highest value is at the bottom of the
stack.

John... Visio MVP

Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
Need VBA examples? http://www.mvps.org/visio/VBA.htm
Common Visio Questions http://www.mvps.org/visio/common_questions.htm
 
B

ben h

Is there more than one stack?

There's only one stack, but the stack could go on to a second page. I
think the array idea is easier for me to implement as I'm used to that
sort of thing.

Thanks John!
 

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