Shape Reports on connections

Started by GivemeVisio, May 11, 2017, 11:09:28 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GivemeVisio

Hi,

Let me preface this by saying I'm using Visio 2016.

I have a couple thousand Visio drawings which have several shapes with multiple connectors (electrical grid). The end-goal is to have the information from these drawings (the shapes and their connectors specifically) stored in a database, so it's easy to search for specific shapes and their connectors.
Now, using the macro posted in this thread http://visguy.com/vgforum/index.php?topic=1127.0 the one to determine flowchart paths, I can successfully get the connectors and their connections.

My problem is that I end up with a list of connectors and their A - B, which doesn't show which shape they're a part of. Is there a macro/Shape Reports feature that can:
a) List shapes followed by their connectors, eg.
        Line 1: Shape1 - connector1 - attached to end-point1
        Line 2: Shape1 - connector2 - attached to end-point2 etc.

b) Include connectors connected to other connectors, eg.
        Line 3: Shape1 - connector3 - attached to connector4
        Line 4: Shape1- connector4 - attached to end-point3


I can attach a sample Visio drawing with sample (preferred) excel output if needed.

Surrogate


wapperdude

In addition, below is reduced file, copied from this post:  http://visguy.com/vgforum/index.php?topic=6314.msg31933#msg31933, reply #17.

Basically, the macro goes thru each page in the Visio drawing, generates an Excel table for each page, inserts the table as a new background page, and saves the Excel file in the same directory where the Visio doc is located.

The Excel table shows connector ID, from shape info, and to shape info.  This works for both connectors connected to pins or to shapes via walking connection.  For pins, if available, pulls up pin number and pin label.  Plus, it adds dots at connection points on connectors.

Either connectors or line shapes are acceptable.

Floating connectors are colored yellow for easy drawing identification.  This can be commented out. 

HTH
Wapperdude
Visio 2019 Pro

GivemeVisio

Thank you for the help, both of you - much appreciated! :)

@wapperdude the Visio drawing you've attached works perfectly but when I copy the macro into my own Visio document, I get a "Compile error: User-defined type not defined" at Sub ExcelReport(ByVal pgCnt, shpCnt, ByRef cnxArry() As Variant)
    Dim XlWrkbook As Excel.Workbook is highlighted as well

It doesn't open Excel at all.

wapperdude

Did you copy just the one macro or all of them?

The Excel macro is called by the main, first macro.  The call passes the necessary info to the Excel macro.

Wapperdude
Visio 2019 Pro

GivemeVisio

I copied the entire bit and placed it in ThisDocument, it shows Conn_Report, ExcelReport and VisPushBack.

wapperdude

Ah, yes.  Forgot that from the VBA window you need to go to Tools > References and add MS Excel 14 Object Library.  Depending upon your installation, the "14" might be higher or lower in value.

Sorry.
Wapperdude
Visio 2019 Pro

GivemeVisio

That did the trick, although it gives an error of "Cannot create object.". Running the macro again right after seems to work fine though.

Attached is my sample Visio drawing which I'm currently using the macro on. Is there a way to make the shape names and connectors their labels instead? Currently it says Square.28 instead of Shape1.
I've attached the Excel output as well, top is how it currently looks like, bottom is how the desired output should be (ideally).

Previous macros get the information extracted but it's not structured in any logical way it seems.

wapperdude

#8
QuoteIs there a way to make the shape names and connectors their labels instead? Currently it says Square.28 instead of Shape1.
Yes and no:
What you show as "Shape1" is merely text.  The code can be modified to get shapetext.  Here is typical modification...

                    Select Case frompartid
                        Case 9                                                  '9 => Source (From Shape) attached to connector Begin
                            Set FromConShp = shp.Connects(i).ToSheet
'Using text for shape name:
                            Dim shpChrs1 As Visio.Characters
                            Set shpChrs1 = FromConShp.Characters
                            Debug.Print shpChrs1
                            cnxArry(0, 0, 0, 0, 0, 0, 0, i, p, shpCnt) = shpChrs1

'                            cnxArry(0, 0, 0, 0, 0, 0, 0, i, p, shpCnt) = FromConShp.Name


Such a change would need to be made for all occurrences of xyz.Name.  So, that aspect is do-able.

But, NO.  Not the way you've constructed your shapes.  Shape1 is not connected to any connectors.  Sheet.28 is actually "2", the small square associated with Shape1.  Normal grouping would not help, as Sheet.28 would still be a separate shape.  The usual grouping, i.e., select all three shapes (Shape1, 1, & 2) then group.  This would create a toplevel shape, which is still not Shape1.  The method should be
   1) Convert Shape1 to group (under shape grouping operations).  This makes Shape1 the top level group shape.
   2) Open shapesheet, under protection, set LockCalcWH = 1
   3) Place "1" & "2" in desired locations and add each to the group
   4) With Shape1 selected, add connection points where needed/desired...at edge of "1" & "2".

Now, when a connector is attached to one of these connection points, the connection point will belong to Shape1 and not either of "1" or "2".  The code will extract the desired shape "name", i.e., text.

Wapperdude
Visio 2019 Pro