MS Access VBA App (2013) finding Connected Shapes

Started by NashParrot, October 27, 2014, 05:15:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

NashParrot

I'm losing what remains of my hair.  I'm trying to import data from a Visio Document into an Access database.  So far, no issues.  I able to iterate through all of the pages, through all of the shapes and get all the data from both the basic properties as well as the Shape Data properties.  Still no issues.

However, I have tried repeatedly to get the connected/glued shapes for both the Incoming and outgoing directly, indirectly... any which way I can.  So far, EXTREMELY unsuccessful.  I have tried MS suggestions, but for all that works inside of Visio VBA, none works inside Access.  I'm open to suggestions.  Here are some of the things I've tried:

1.
                    shpIDs = shpObj.ConnectedShapes _
                      (visConnectedShapesOutgoingNodes, "")
                    Debug.Print "Shapes at the end of outgoing connectors:"
                    For j = 0 To UBound(shpIDs)
                        Debug.Print shpObjs(shpIDs(j)).Name
                    Next

2.
                    Debug.Print "2D Incoming shape from " & shp.Name
                    shpIDs = shpObj.GluedShapes(visGluedShapesIncoming2D, "")
                    For j = LBound(shpIDs) To UBound(shpIDs)
                        Debug.Print pagObj.Shapes.ItemFromID(shpIDs(j))
                    Next

In both cases "shpIDs" is an array defined as Dim shpIDs() as Long

In the first case, my Ubound is always 0 (even when I have multiple connections) and in the second, the Ubound ends up being -1.

Is there something obvious I'm missing, or is this just not possible?

Thanks!

Oh, as an interesting note, I can get shpObj.ConnectedShapes(visConnectedShapesIncomingNodes, "") to return a value in Visio, but in Access it gives me an error ("Out of memory").

Croc

#1
Probably, You need to determine the constants like visConnectedShapesOutgoingNodes.
visConnectedShapesOutgoingNodes = 2

NashParrot

#2
In 1. I set the constant for the nodes.  Are there other constants I'm not seeing?

Croc

Maybe I am mistaken ...
Seems Visio VBA knows that visConnectedShapesOutgoingNodes = 2, and Access VBA does not know.

Yacine

Hi NashParrot,
The connectedShapes function is proper to Visio 2010 and later.
In the link bellow, I tried to show how to get linked shapes with functions of V2007. I'm pretty sure they work for later versions too.
Have look, you may find what you're looking for.
http://visguy.com/vgforum/index.php?topic=6021.msg24362;topicseen#msg24362
Yacine

NashParrot

Yacine, This is Access 2013 and Visio 2013, so I would think that the connectedShapes should work... right?  I will look at your other thread, but not sure I actually understand the code.  Thank you for the suggestion though.  I will try to figure it out.

cliff50

Hi,

in your post -> "....I can get shpObj.ConnectedShapes(visConnectedShapesIncomingNodes, "") to return a value in Visio

This is fine in the Visio VBA environment.

My approach is to use the Visio VBA to populate MS Access tables with the Visio shape to shape connection information.

"the knee bone connected to the shin bone etc etc"

My question would be why do you require the Access VBA to map into the Access table structures the Visio inter-shape connections, when it appears that you have found functionality within Visio VBA to identify shape inter connectivity and most likely the ability to populate Access tables with that information.

My thoughts are >>Try to code the Visio application to populate the access tables

cheers

aledlund

VBA is not necessarily VBA, different products use different libraries (i.e. Access VBA libraries do not include, or even share, all of the same calls) so you have to remember to add the Visio libraries to your reference list in the access project. One of the other hassels is that when referring to the 'Application' within a solution that is shared with Access, sometimes the host App (Access) will take over the call rather than the guest application (Visio).
Another fact that can sometimes be overlooked is that visio connectors are directional (so the inbound and outbound connections can become confused) even though the user 'knows' the path is outbound drawing it from the remote to the center tells a different story. As a suggestion before playing with a list of shapeid's test to make sure the list exists and is not zero length. It is possible for a null list to be returned.
hth,
al