VBA Code: Help with naming connectors and creating port matrix: Visio 2010

Started by Chuckcm94, July 12, 2016, 10:23:24 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Chuckcm94

 Hello, I have a question on creating a VBA code that will display which ports of components are connected to each other in Excel . I also want to know if it is possible to name my ports in Visio. Please refer to the image attached and read through my examples to get a better understanding.

Question 1( refer to the image I uploaded.): Is there a VBA code out that will show for that component 1's port 1 is connected to component 2's port 2 via the " red wire?" This would be useful for the port matrix file I am trying to create in excel. That way I will not have to type it manually.

Question 2: Would it be possible to do this procedure for multiple Visio pages at once that will make multiple Excel pages?

I tried to use the " Path Analysis in Visio" code that Visio Guy created but that did not work for me. Is someone has a code for this, it will be very helpful :) .

bmwk100dk

Hi Chuckcm94

I'm no expert in VBA or progamming in general, but I just came across this link, and thought it might be useful for what you want.

https://blog.bvisual.net/2013/05/21/getting-the-name-of-glued-connection-points/



Good luck with your project.

Best regards
bmwk100dk

wapperdude

You might also be interested in the following:

Topic: Schematic capture schema: connectivity, reports, diagnostics :  http://visguy.com/vgforum/index.php?topic=6314.0  The code is not as well organized as David Parker's, but it does show some features not covered.   There is also a section for creating an Excel spread sheet.

Topic: Visio VBA Export Shapedata to Excel, and copy back to Visio:  http://visguy.com/vgforum/index.php?topic=7302.0    The code is more structured.  Includes exporting to Excel

HTH
Wapperdude
Visio 2019 Pro

Chuckcm94

@wapperdude I tried both of your codes but they did not work.

The first one gave the error message in the first picture two pictures I attached. The second one gave an error message saying that there were no re portable shapes in the active page. May you help me fix these? Is there anything I should so to my Visio pages or objects to make these codes work?


Chuckcm94

@wapperdude Here is the error code for the 2nd code you sent me.

wapperdude

With regards to the 2nd link.  The example code is looking for shape data.  If none of the shapes, it only considers 2D shapes, have shape data, you get the  no reportable shapes on the page.  I referred to this link to study the code.

With regards to the first link, there's a lot that goes on.  Part of it is setting up the 2D shapes.  That has to be done by hand.  Of particular interest are the connection points, which use named rows and the D cell.    It's been awhile since I ran this, but the post should explain everything.  There are two macros.  One goes through and does all of the circuit evaluations, the 2nd controls how everything is displayed. That 1st macro does a lot of initialization to the 1D shapes.  Part of that is establishing a lot of User Defined entries in the shapesheet. 

If the code is stopping at the point indicated, halt the code before that line executes.  Then, see if the arguments have values, and check the "shp" shapesheet has the cells being referred to.

Did the code run in the provided Visio file?  Make a duplicate, delete one shape, replace it with one of yours, re-run the code.  That will help pinpoint source of error in a controlled environment.

Wapperdude
Visio 2019 Pro

wapperdude

Re-worked the code to be more friendly.  Think all of the errors have been eliminated.  The attached code is much simpler to follow.  There are 3 macros in the file.

The main macro, Case_1D_shapes2(), gathers all of the information.  Every shape on every page is analyzed.  The data is stored in a dynamic array.  The program does a debug.print to show what's on each page.  The code has hooks to get the connection point info, but, as of this posting, nothing is being done with this info.

The second macro provided could be adapted to take the array contents and push the data into Excel worksheet.

The last macro calls back the Excel worksheet contents and places it in the Visio file on a new drawing page as an imported worksheet.  There should be enough info here to solve your problem, assuming you haven't already done so.

HTH
Wapperdude
Visio 2019 Pro

wapperdude

File has been updated.  The array has been expanded to include the status info of the connection points include the type and the D-Cell entry.

The main macro also will highlight floating connectors and lines, that is, those that only have one end connected.  Additionally, if a connector or line are connected to another connector or line, a dot is added to show connectivity.  Thus, there are two visual aids to indicate lack of connectivity.  Line color and no dots.

The ship to / from Excel macros have not been updated.

Wapperdude
Visio 2019 Pro