Glued to Method has errors

Started by wapperdude, September 09, 2019, 01:50:34 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wapperdude

I don't think this is unique to V2019, but it is what I'm using.  This is simple test.  Just a few shapes on a page with some connectors.  Simple macro.  I'm only interested in shapes connected to the connectors.  Not interested in the case of which connectors are glued to a shape.  The code runs, lists a connector and then lists the incoming and outgoing shapes connected to it.  Pretty simle indeed.  However, I found a couple of cases, which ought to be legitimate connectivity scenarios where the gluedto method gets it wrong.

Don't think I missed any thing.  Let me know.
Visio 2019 Pro

Yacine

Can't see the error.
Here's the output on my machine:
Dynamic connector
Incoming 2D shapes
Sheet.1
Outgoing 2D shapes
Sheet.2


Dynamic connector.5
Incoming 2D shapes
Sheet.2
Outgoing 2D shapes
Sheet.4



Dynamic connector.8
Incoming 2D shapes
Sheet.6
Outgoing 2D shapes
Sheet.7


Dynamic connector.11
Incoming 2D shapes
Sheet.9
Outgoing 2D shapes
Sheet.7
Yacine

wapperdude

Oops.  Should have also said...1st two pages work as expected, they're Good1 and Good2.  Second set of pages, Err1 and Err2, have reporting errors.  It's always at the end of the listings as I recall.  Will upload examples when I'm at my computer.
Visio 2019 Pro

Yacine

#3
The error is in the way you address the shapes. Use ...shapes.ItemFromID(..) instead of the direct assignment shapes(..).
Explanation: On the first page the index corresponds to the ID, after duplicating it's different ? ? ? ? No real clue.
Yacine

wapperdude

#4
Hmmm.  As I look closer, yes, some of the indexing looks like it is wrong.  For example, Error2 page has a shape, Sheet.10, and a connector, Dyn Conn.10.  That's not right.  Will create same connectivity, but, without the indexing errors.  Very strange why those are there.  Didn't think THAT was possible.  So, perhaps a BUG, just not the one I thought!!!

The Good1 page was first page populated.  The 2nd page, was Error1.  It was populated using copy All / paste.  Then edited.  Similarly with 3rd page which was Error2.  Finally, Good4, done same way, was the 4th page.

As for code, it's straight from M$.

Will try with corrected indexing.
Thanks for the idea.  Certainly worth exploring.
Visio 2019 Pro

wapperdude

#5
Indeed it was bad indexing.

What's weird, the indexing error occurs when do select all, copy, and then paste to new page.  Don't ever remember seeing that in V2007.

Thanks Yacine.

Oh, there is still a bug in the Glue to Method.  If you connect a connector to the middle of another connector (glued, not just snapped), it doesn't know what to do.  See last page of updated file. Somewhat reasonable...is the glued connector an incoming or outgoing shape.  Well, depends upon which end has been glued.  The method   doesn't seem to handle that.

Well, instead of one bug, there's two bugs. 

Can anyone verify the copy/paste bug with other versions of Visio.  Be nice to know when it appeared, or if it's unique to my instantiation of Visio.
Visio 2019 Pro

wapperdude

Well.  Found solution for connector connector combination.  Almost.  It catches incoming and outgoing, but doesn't always get the directionality correct. 

The key, was as Yacine suggested, change the syntax.
Was:  ActivePage.Shapes(shpIDs(i)).Name
Becomes:  ActivePage.Shapes.ItemFromID(shpIDs(i)).Name

See attached file...
Visio 2019 Pro