visio How can i find traverse a flowchart in vba

I have a simply workflow in visio I would like to, on the press of a button, to

1) Find out what shapes I have
2) What is connected to each of the shapes.

in vba.

I have added an example of the diagram which i would ike to be able to traverse
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott HelmersVisio Consultant, Trainer, Author, and DeveloperCommented:
Though it seems like this should be an obvious feature of Visio --  it's not. There is no innate knowledge of "connectedness" in any version of Visio up to and including Visio 2007. It is possible to determine connectivity using code  but it's not as easy as you'd think.

For example, the Visio  drawing below contains macro code to determine what is at each end of  every line on the page. I created this code in response to another EE  question.  In that case, the user's goal was to produce a report showing the text  of the shapes at each end of every line. To make that possible the code  creates two shape data fields on each line and stores the text of each  endpoint shape in those fields. (NOTE: "shape data" was called "custom  properties" prior to Visio 2007)

To see how it works, open the  attached drawing in Visio, then open the Shape Data Window (View>Shape  Data Window). Before you run the macro, click on a couple of the  existing lines and you'll see that there is no shape data. Then run the  macro (Tools>Macro>ThisDocument>GetFlowchartConnections).  Now when you click on each line you'll see the text of the endpoint  shapes stored in fields called "From" and "To".

Now that each connector knows what it's connected to, you have several options for displaying the data. For example, you could write more VBA code to display the data in the Visio drawing or do something else with it. Or if you'd like a very simple but effective alternative, you can use the Visio report wizard to create a report on this data (Visio 2003: Tools>Reports   Visio 2007: Data>Reports)

If you want to get even more sophisticated, there is sample code in the Visio SDK for navigating a Visio drawing.  However, rather than start with the SDK directly, here's an excellent article on path analysis that incorporates and expands on the SDK code:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott HelmersVisio Consultant, Trainer, Author, and DeveloperCommented:
I forgot to mention that Visio 2010 incorporates the idea of "connectedness" for the first time. So if you're using Visio 2010, the above code will still work, however there are more efficient ways to get the job done.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.