If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
".Connects" member
Hi everyone. I am trying to access the connects for a selection of
shapes. All my connectors are double-headed arrows, I'm not sure if that makes a difference or not. Here is the code I am using: Sub TestMac() Dim vsoSelect As Visio.Selection Dim vsoShape As Visio.Shape Dim vsoConnects As Visio.Connects Dim vsoConnect As Visio.Connect Set vsoSelect = Visio.ActiveWindow.Selection vsoSelect.IterationMode = Visio.VisSelectMode.visSelModeSkipSuper For Each vsoShape In vsoSelect Debug.Print vsoSelect.Count Set vsoConnects = vsoShape.Connects Debug.Print vsoConnects.Count Next vsoShape End Sub ----- The vsoShape.Connects line is returning 0 every time. If I use the FromConnects member instead of Connects, it returns the correct number. I need to access the Connects however, as I need to find the actual shapes that each shape in my selection connect to. Does anyone know what I am missing? Thanks in advance. |
#3
|
|||
|
|||
".Connects" member
On Feb 17, 1:13*pm, Paul Herber
wrote: On Tue, 17 Feb 2009 09:19:55 -0800 (PST), wrote: Hi everyone. I am trying to access the connects for a selection of shapes. All my connectors are double-headed arrows, I'm not sure if that makes a difference or not. Here is the code I am using: Sub TestMac() Dim vsoSelect * * * As Visio.Selection Dim vsoShape * * * *As Visio.Shape Dim vsoConnects * * As Visio.Connects Dim vsoConnect * * *As Visio.Connect * *Set vsoSelect = Visio.ActiveWindow.Selection * *vsoSelect.IterationMode = Visio.VisSelectMode.visSelModeSkipSuper * *For Each vsoShape In vsoSelect * * * *Debug.Print vsoSelect.Count * * * *Set vsoConnects = vsoShape.Connects * * * *Debug.Print vsoConnects.Count * *Next vsoShape End Sub ----- The vsoShape.Connects line is returning 0 every time. If I use the FromConnects member instead of Connects, it returns the correct number. I need to access the Connects however, as I need to find the actual shapes that each shape in my selection connect to. Does anyone know what I am missing? So, why not use the FromConnects instead, the count is right, you can then iterate through the FromConnects.Items and look at the connections to see where they go. -- Regards, Paul Herber, Sandrila Ltd. Electronics for Visio * *http://www.electronics.sandrila.co.uk/- Hide quoted text - - Show quoted text - Going through the from connects collection is returning information on the connectors themselves and the original shapes I have selected. I have tried every iteration of FromSheet and ToSheet and I am getting only the two things I mentioned (the connector and the original shape). I was pretty sure the Connects member could help me get information on the secondary shapes, as I can think of no solution using FromConnects. |
#4
|
|||
|
|||
".Connects" member
This requires some abstract thinking. When we look a drawing of two shapes
with a connecting line, we see Shape A connected to Shape B. What Visio sees is Shape A connected to a connector and the connector connected to Shape B. So what you need to look at is the connection collections for the connecting shape. Another key point is that there is directionality to the connection collections. The reference to the connector may be in Shape A's Connect collection, but it's from collection is empty while it is the reverse for the connector. There is a better explanation here. http://msdn.microsoft.com/en-us/libr...ffice.10).aspx John.. Visio MVP wrote in message ... On Feb 17, 1:13 pm, Paul Herber wrote: On Tue, 17 Feb 2009 09:19:55 -0800 (PST), wrote: Hi everyone. I am trying to access the connects for a selection of shapes. All my connectors are double-headed arrows, I'm not sure if that makes a difference or not. Here is the code I am using: Sub TestMac() Dim vsoSelect As Visio.Selection Dim vsoShape As Visio.Shape Dim vsoConnects As Visio.Connects Dim vsoConnect As Visio.Connect Set vsoSelect = Visio.ActiveWindow.Selection vsoSelect.IterationMode = Visio.VisSelectMode.visSelModeSkipSuper For Each vsoShape In vsoSelect Debug.Print vsoSelect.Count Set vsoConnects = vsoShape.Connects Debug.Print vsoConnects.Count Next vsoShape End Sub ----- The vsoShape.Connects line is returning 0 every time. If I use the FromConnects member instead of Connects, it returns the correct number. I need to access the Connects however, as I need to find the actual shapes that each shape in my selection connect to. Does anyone know what I am missing? So, why not use the FromConnects instead, the count is right, you can then iterate through the FromConnects.Items and look at the connections to see where they go. -- Regards, Paul Herber, Sandrila Ltd. Electronics for Visio http://www.electronics.sandrila.co.uk/- Hide quoted text - - Show quoted text - Going through the from connects collection is returning information on the connectors themselves and the original shapes I have selected. I have tried every iteration of FromSheet and ToSheet and I am getting only the two things I mentioned (the connector and the original shape). I was pretty sure the Connects member could help me get information on the secondary shapes, as I can think of no solution using FromConnects. |
#5
|
|||
|
|||
".Connects" member
Okay, that makes a lot of sense. What I got out of it was that the
shape won't have a connects collection, but the connector will. So I need to access the connectors connects collection, through the ToSheet property. This is what I added to the code which made sense to me, but I am getting a type mismatch. ----- Set vsoShapeTo = vsoConnect.ToSheet.Connects Debug.Print vsoShapeTo.Text ----- Where vsoShapeTo is a Visio.Shape type. The website said that Connects from ToSheet returns a single shape, but I am getting a 'type mismatch' compilation error. Would you have any suggestions? Thanks John. |
#6
|
|||
|
|||
".Connects" member
wrote in message
... Okay, that makes a lot of sense. What I got out of it was that the shape won't have a connects collection, but the connector will. So I need to access the connectors connects collection, through the ToSheet property. This is what I added to the code which made sense to me, but I am getting a type mismatch. ----- Set vsoShapeTo = vsoConnect.ToSheet.Connects Debug.Print vsoShapeTo.Text ----- Where vsoShapeTo is a Visio.Shape type. The website said that Connects from ToSheet returns a single shape, but I am getting a 'type mismatch' compilation error. Would you have any suggestions? Thanks John. Each shape has two connection collections. The shapes that it connects to and the shapes that connects to it. So you should be able to find the relationship between both shapes by looking in both collections. Once you find the first round of shapes, then you need to repeat the process for the connector's connection collections. John... Visio MVP |
#7
|
|||
|
|||
".Connects" member
Yes, I'm trying to access both collections. The FromSheet is working
alright but I am getting a type mismatch for the ToSheet |
#8
|
|||
|
|||
".Connects" member
wrote in message
... Yes, I'm trying to access both collections. The FromSheet is working alright but I am getting a type mismatch for the ToSheet Post the code. ;-) John... Visio MVP |
#9
|
|||
|
|||
".Connects" member
Public Sub Macro1()
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 Dim vsoShapeTo As Visio.Shape Dim intCounter As Integer Set vsoSelect = Visio.ActiveWindow.Selection vsoSelect.IterationMode = Visio.VisSelectMode.visSelModeSkipSuper Debug.Print vsoSelect.Count If vsoSelect.Count 0 Then For Each vsoShape In vsoSelect Set vsoConnects = vsoShape.FromConnects For Each vsoConnect In vsoConnects Set vsoShapeTo = vsoConnects.ToSheet.Connects Debug.Print vsoShape.Text; " connects with "; vsoShapeTo.Text Next vsoConnect Next vsoShape Else MsgBox "You Must Have Something Selected" End If Close #1 End Sub |
#10
|
|||
|
|||
".Connects" member
Thanks for your help!
|
|
Thread Tools | |
Display Modes | |
|
|