Hi,
Any code to list which 1D connectors are attached to a 2D shape.
I have a code that lists the source and target 2D shape for a 2D shape, but not a 1D shape source/target!
This is what I have:
Public Sub ListNextConnections()
Dim shp As Visio.Shape
Dim connectorShape As Visio.Shape
Dim sourceShape As Visio.Shape
Dim targetShape As Visio.Shape
Dim aryTargetIDs() As Long
Dim arySourceIDs() As Long
Dim targetID As Long
Dim sourceID As Long
Dim i As Integer
For Each shp In Visio.ActivePage.Shapes
If Not shp.OneD Then
If shp.CellExists("Prop.NetworkName", Visio.visExistsAnywhere) Then
Debug.Print "Shape", shp.Name, shp.Cells("Prop.NetworkName").ResultStr("")
arySourceIDs = shp.ConnectedShapes(visConnectedShapesOutgoingNodes, "")
For i = 0 To UBound(arySourceIDs)
Set sourceShape = Visio.ActivePage.Shapes.ItemFromID(arySourceIDs(i))
If sourceShape.CellExists("Prop.NetworkName", Visio.visExistsAnywhere) Then
Debug.Print , "<", sourceShape.Name, sourceShape.Cells("Prop.NetworkName").ResultStr("")
End If
Next
aryTargetIDs = shp.ConnectedShapes(visConnectedShapesIncomingNodes, "")
For i = 0 To UBound(aryTargetIDs)
Set targetShape = Visio.ActivePage.Shapes.ItemFromID(aryTargetIDs(i))
If targetShape.CellExists("Prop.NetworkName", Visio.visExistsAnywhere) Then
Debug.Print , ">", targetShape.Name, targetShape.Cells("Prop.NetworkName").ResultStr("")
End If
Next
End If
End If
Next
Any way we can tweak the code to list the incoming/outgoing 1D connectors????
Regards
prasanna2j
there is probably someting in here that will help
http://www.visguy.com/2009/04/08/path-analysis-in-visio/
al
I got some code on microsoft website, which kinda solves my problem. Here it is
Public Sub GetGluedShapes()
'Use Shape.GluedShapes to get the shapes that are glued to a shape
Dim shp As Visio.Shape
Dim shpIDs() As Long
Dim i As Integer
'MsgBox "GluedShapes"
If ActiveWindow.Selection.Count = 0 Then
MsgBox ("select a shape with connections")
Exit Sub
Else
Set shp = ActiveWindow.Selection(1)
End If
shpIDs = shp.GluedShapes(visGluedShapesIncoming1D, "")
'MsgBox "Incoming 1D shapes"
For i = 0 To UBound(shpIDs)
MsgBox ActivePage.Shapes(shpIDs(i)).Name
Next
shpIDs = shp.GluedShapes(visGluedShapesOutgoing1D, "")
'MsgBox "Outgoing 1D shapes"
For i = 0 To UBound(shpIDs)
MsgBox ActivePage.Shapes(shpIDs(i)).Name
Next
shpIDs = shp.GluedShapes(visGluedShapesIncoming2D, "")
'MsgBox "Incoming 2D shapes"
For i = 0 To UBound(shpIDs)
MsgBox ActivePage.Shapes(shpIDs(i)).Name
Next
shpIDs = shp.GluedShapes(visGluedShapesOutgoing2D, "")
'MsgBox "Outgoing 2D shapes"
For i = 0 To UBound(shpIDs)
MsgBox ActivePage.Shapes(shpIDs(i)).Name
Next
End Sub
hello prasanna2j,
I am trying to list the incoming/outgoing 1D connected shapes to a selected Shape, your example is very useful but I have the "invalid sheet identifier" error... Any idea how to fix this ?
Thank you
Just as an assumption I'd start by examining the version of Visio, a lot of enhancements to analyzing connectivity came in the v2010 version.
al
One thing that might make the task easier is that when a connector is connected, the shapes the "from" and "to" cells are populated. could just walk thru all shapes and look in those cells for where coming from and where going.
Just something that might help.
I have Visio 2010 version...
I think that's a good idea to look at these cells... Is there any documentation or a link in which I can find all the cells related to the Shape object ?? because I can't find these "from" and "to" cells
These aren't cells (shpIDs = shp.GluedShapes(visGluedShapesIncoming2D, "")), they are methods. It's a derived call.
al
I was talking about vojo's post, maybe I misunderstood what he meant.
The GluedShapes method : GluedShapes(visGluedShapesIncoming1D, "")
does not seem to work well for me and I need to list connected shapes to my selected shape
in 2003
Cell Begtrigger and Endtrigger cells.....parse their values and react as appropriate....sort of filters the shape types for you
What happend to the shapes connects-collection. Can't u use that in VBA?
Now it works
I parse all the connections in my Visio page, for each one I get the shp.Connects.Count and with a For loop I get the shp.Connect
(i).ToCell.shape and so on I get all the linked shapes with that connection
shp.Connect(i).ToShape or was it .ToSheet shpuld give you the shape directly without the detour via Tocell.Shape
yes Jumpy,
shp.Connect(i).ToSheet return the same result :)
Thanks
Browser ID: smf
(is_webkit)
Templates: 1:
Printpage (default).
Sub templates: 4:
init,
print_above,
main,
print_below.
Language files: 1:
index+Modifications.english (default).
Style sheets: 0:
.
Hooks called: 84 (
showintegrate_autoload, cache_get_data, integrate_pre_load, integrate_load_session, integrate_verify_user, cache_get_data, integrate_user_info, integrate_load_board, cache_get_data, integrate_board_info, cache_get_data, integrate_allowed_to_general, integrate_allowed_to_general, integrate_boards_allowed_to, integrate_mod_cache, integrate_allowed_to_general, integrate_pre_load_theme, cache_get_data, integrate_allowed_to_general, integrate_simple_actions, integrate_allowed_to_general, integrate_load_theme, integrate_pre_log_stats, cache_get_data, integrate_actions, integrate_pre_parsebbc, integrate_bbc_codes, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_menu_buttons, integrate_current_action, integrate_theme_context, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general)
Files included: 25 - 925KB. (
show/home/iw0lkfe3x6cq/public_html/vgforum/index.php, /home/iw0lkfe3x6cq/public_html/vgforum/Settings.php, /home/iw0lkfe3x6cq/public_html/vgforum/cache/db_last_error.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/QueryString.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Auth.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Errors.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Load.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Security.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Compat.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Db-mysql.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/CacheApi.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/CacheApiInterface.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/APIs/FileBased.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Charset.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/Metadata.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/QuickCheck.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Session.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Logging.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Class-BrowserDetect.php, (Current Theme)/languages/index.english.php, (Current Theme)/languages/Modifications.english.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Printpage.php, (Current Theme)/Printpage.template.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/CaseUpper.php)
Memory used: 774KB.
Tokens:
post-login.
Cache hits: 8: 0.00111s for 22,302 bytes (
showget modSettings: 0.00038s - 19983 bytes, get known_languages: 0.00016s - 1277 bytes, get board_parents-0: 0.00011s - 2 bytes, get permissions:-1: 0.00012s - 50 bytes, get theme_settings-1: 0.00009s - 980 bytes, get hostlookup-216.73.216.125: 0.00001s - 0 bytes, get log_online-update: 0.00021s - 10 bytes, get menu_buttons--1-english: 0.00003s - 0 bytes)
Cache misses: 2: (
showget hostlookup-216.73.216.125, get menu_buttons--1-english)
Queries used: 11.
[Show Queries]