Visio Guy

Visio Discussions => General Visio => Topic started by: PF4VisioGuy on February 15, 2017, 04:27:08 AM

Title: Looking for an example to generate shapes and connect them programatically
Post by: PF4VisioGuy on February 15, 2017, 04:27:08 AM
I have pairs of values and I need to connect them together. Imagine numbers in circles that will be connected to each other via straight lines , the numbers indicate the steps of a process.

I would like to read documentation or see examples  for this
Importing all the data from an excel table is fine
Title: Re: Looking for an example to generate shapes and connect them programatically
Post by: wapperdude on February 15, 2017, 07:34:11 AM
The attached example has two macros.  One shows how to grab a range of cells, could be just two cells, and place them on a Visio drawing page.  The code, MyMac, asks for an Excel file, which can be found by normal tree search method.  Then, opens the file and asks for a range of cells.  Each cell is sequentially placed and formatted onto the Visio page.

The 2nd macro is hard coded to drop a connector and glue it to two shapes. 

I think both of these macros are reasonably straight forward and can be easily adapted for your needs.

Enjoy.
Wapperdude
Title: Re: Looking for an example to generate shapes and connect them programatically
Post by: PF4VisioGuy on February 16, 2017, 04:14:54 AM
Thank you, I will give it a try
Title: Re: Looking for an example to generate shapes and connect them programatically
Post by: wapperdude on February 16, 2017, 06:37:17 AM
Guess I should have asked, what version of Visio?


Wapperdude
Title: Re: Looking for an example to generate shapes and connect them programatically
Post by: wapperdude on February 16, 2017, 04:22:06 PM
I reworked the MyMac code to automatically minimize, maximize the Excel window.  It tends to get in the way. 

In addition, I changed the Excel retrieval process.  Now it takes the cells, 2 by 2, and calls the add connector to "link" them together.

Wapperdude