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 |
#21
|
|||
|
|||
Using Selection
wrote in message
... Hi Sachin. The carriage returns are the key as I have discovered using this code as well. Also, the msg box issue was fixed after I fooled around with it a bit. I ended up just hard coding a loop through the shapes I was working with. I am experiencing a related problem, however. I want to find explicit connections as in ShapeA connects with ShapeB etc... using the actual shape text. The ToSheet command is returning a shape text, however the FromSheet command is returning the text of a connector, not a shape. Does anyone know of another command that will return the shape text on the other side of the connector? Thanks, Damascus When normal humans like us look at a Visio drawing we see Shape A connected to Shape B. When Visio looks at the same drawing it sees Shape A connected to a connector shape and the connector shape connected to Shape B. So you will have to check the From/To connections of the connector to find Shape B. You may also want to verify that the shape ShapeA is connected to is a 1d shape (typical for most connections). John... Visio MVP |
#22
|
|||
|
|||
Using Selection
Hi John. I am using this piece of code to access the information I am
trying to get: Dim vsoShapes As Visio.Shapes Dim vsoShape As Visio.Shape Dim vsoConnectTo As Visio.Shape Dim vsoShapeTo As Visio.Shape Dim vsoConnectWith As Visio.Shape Dim vsoConnects As Visio.Connects Dim vsoConnect As Visio.Connect Dim intShapeIndex As Integer Dim intConIndex As Integer Dim intCounter As Integer Set vsoShapes = ActivePage.Shapes 'For each shape on the page, get its connections. For intShapeIndex = 1 To vsoShapes.Count Set vsoShape = vsoShapes(intShapeIndex) Set vsoConnects = vsoShape.Connects 'For each connection, get the shape it connects to. For intCounter = 1 To vsoConnects.Count Set vsoConnect = vsoConnects(intCounter) Set vsoConnectTo = vsoConnect.ToSheet Set vsoConnectWith = vsoConnect.FromSheet Set vsoShapeTo = vsoConnectWith.FromConnects 'I added this as an experiment right now, give a compilation error (mismatch) Debug.Print vsoConnectTo.Text; " connects with "; vsoShapeTo.Text Debug.Print " " --- I won't bore you with the loop close statements etc... this is the important part anyways. It seems like I AM using the connector and not the shape for FromSheet and ToSheet. I tried that last bit of code to see if that would use the connnector as opposed to the shape, but I got the mismatch. Do you have any suggestions? Greatly appreciated, Damascus |
#23
|
|||
|
|||
Using Selection
wrote in message
... Hi John. I am using this piece of code to access the information I am trying to get: Dim vsoShapes As Visio.Shapes Dim vsoShape As Visio.Shape Dim vsoConnectTo As Visio.Shape Dim vsoShapeTo As Visio.Shape Dim vsoConnectWith As Visio.Shape Dim vsoConnects As Visio.Connects Dim vsoConnect As Visio.Connect Dim intShapeIndex As Integer Dim intConIndex As Integer Dim intCounter As Integer Set vsoShapes = ActivePage.Shapes 'For each shape on the page, get its connections. For intShapeIndex = 1 To vsoShapes.Count Set vsoShape = vsoShapes(intShapeIndex) Set vsoConnects = vsoShape.Connects 'For each connection, get the shape it connects to. For intCounter = 1 To vsoConnects.Count Set vsoConnect = vsoConnects(intCounter) Set vsoConnectTo = vsoConnect.ToSheet Set vsoConnectWith = vsoConnect.FromSheet Set vsoShapeTo = vsoConnectWith.FromConnects 'I added this as an experiment right now, give a compilation error (mismatch) Debug.Print vsoConnectTo.Text; " connects with "; vsoShapeTo.Text Debug.Print " " --- I won't bore you with the loop close statements etc... this is the important part anyways. It seems like I AM using the connector and not the shape for FromSheet and ToSheet. I tried that last bit of code to see if that would use the connnector as opposed to the shape, but I got the mismatch. Do you have any suggestions? Greatly appreciated, Damascus You have to be careful with your apples and oranges. vsoShapeTo is a Visio shape, but FromConnects is a Connection collection. So you will have to loop through the connections: 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 John... Visio MVP |
#24
|
|||
|
|||
Using Selection
I thought I incorporated the nested loop correctly, but I am still
getting the same results. Here is how i did it: Public Sub MasterConnectivityList() Dim vsoShapes As Visio.Shapes Dim vsoShapeA As Visio.Shape Dim vsoConnectTo As Visio.Shape Dim vsoConnectWith As Visio.Shape Dim vsoConnects As Visio.Connects Dim vsoConnect As Visio.Connect Dim intCurrentShapeIndex As Integer Dim intCounter As Integer Set vsoShapes = ActivePage.Shapes 'For each shape on the page, get its connections. For intCurrentShapeIndex = 1 To vsoShapes.Count Set vsoShapeA = vsoShapes(intCurrentShapeIndex) Set vsoConnects = vsoShapeA.Connects 'Loop through connects For intCounter = 1 To vsoConnects.Count Set vsoConnect = vsoConnects(intCounter) Set vsoConnectTo = vsoConnect.ToSheet ************************************************** ****************************** Loop through connects, getting the shape they connect with For Each vsoConnect In vsoConnects Set vsoConnectWith = vsoConnect.FromSheet Next vsoConnect ************************************************** ****************************** 'Print the name of the shape the 'Connect object connects to. Debug.Print vsoConnectTo.Text; " connects with "; vsoConnectWith.Text Debug.Print " " Next intCounter Next intCurrentShapeIndex End Sub |
#25
|
|||
|
|||
Using Selection
Does it not seem there like it is looping through the connections? I
am confused now. Thanks for sticking with me and all of your help John. Damascus |
Thread Tools | |
Display Modes | |
|
|