Thread: Using Selection
View Single Post
  #18  
Old February 5th, 2009, 01:43 PM posted to microsoft.public.visio.general
Sachin[_2_]
external usenet poster
 
Posts: 15
Default Using Selection

Well I'm working with the exact same code you gave me, John.
---

Dim vsoConnect As Visio.Connect
Dim vsoConnects As Visio.Connects
Dim vsoSelect As Visio.Selection
Dim vsoShape As Visio.Shape
Dim vsoShapes As Visio.Shapes


Set vsoSelect = Visio.ActiveWindow.Selection


Debug.Print vsoSelect.Count
If vsoSelect.Count 0 Then
'For each shape in the selection, get its connections.
For Each vsoShape In vsoSelect


Set vsoConnects = vsoShape.Connects


'For each connection, get the shape it connects to.
For Each vsoConnect In vsoConnects


'Print the name of the shape the
'Connect object connects to.
Debug.Print vsoShape.Name; " connects to ";
vsoConnect.ToSheet.Name


Next vsoConnect


Set vsoConnects = vsoShape.FromConnects


'For each connection, get the shape it connects to.
For Each vsoConnect In vsoConnects


'Print the name of the shape the
'Connect object connects to.
Debug.Print vsoShape.Name; " is connected from ";
vsoConnect.FromSheet.Name


Next vsoConnect


Next vsoShape
Else
MsgBox "You Must Have Something Selected"
End If
---

There is a compilation error with the lines "vsoConnect.ToSheet.Name",
and "vsoConnect.FromSheet.Name". If I comment them out to see if the
rest of the macro runs properly, it runs but gives me the message box
no matter what. I am not hard coding for anything. When I was working
with this in the past, I don't remember the message box error. I do
remember the .Name errors but I forget how I got around them.
Unfortunately when I was using this before we didn't end up going
through and using the macro, and I foolishly didn't save what I had.