A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Powerpoint, Publisher and Visio » Visio
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

".Connects" member



 
 
Thread Tools Display Modes
  #11  
Old February 18th, 2009, 06:07 PM posted to microsoft.public.visio.general
[email protected]
external usenet poster
 
Posts: 32
Default ".Connects" member

Public Sub ImmediateNeighbours()

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 to ";
vsoShapeTo.Text

Next vsoConnect

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

Close #1

End Sub
  #13  
Old February 18th, 2009, 06:41 PM posted to microsoft.public.visio.general
[email protected]
external usenet poster
 
Posts: 32
Default ".Connects" member

That was the first thing I tried. I have experimented with a ton of
iterations and I tried to post the original one I thought made sense
but I guess I made that typo.


vsoConnect.ToSheet.Connects gives the type mismatch.
  #15  
Old February 19th, 2009, 01:49 PM posted to microsoft.public.visio.general
[email protected]
external usenet poster
 
Posts: 32
Default ".Connects" member

Set vsoConnects = vsoShape.From Connects
For Each vsoConnect In vsoConnects
-----
Is identical to:
-----
For Each vsoConnect In vsoShape.FromConnects
-----
  #16  
Old February 19th, 2009, 02:20 PM posted to microsoft.public.visio.general
John... Visio MVP
external usenet poster
 
Posts: 900
Default ".Connects" member

wrote in message
...
Set vsoConnects = vsoShape.From Connects
For Each vsoConnect In vsoConnects
-----
Is identical to:
-----
For Each vsoConnect In vsoShape.FromConnects
-----



It is, but it has one less variable (that can be easily confused) to deal
with and dispose of.

The less clutter the easier it is to read what the code is doing. Some of
the examples on the Visio VBA page use the "For i = 1 to count" structure
and I should take some time and simplify it to "For Each" structures.

John... Visio MVP

  #17  
Old February 19th, 2009, 02:45 PM posted to microsoft.public.visio.general
[email protected]
external usenet poster
 
Posts: 32
Default ".Connects" member

Ahh okay. I misunderstood you before, I thought you were proposing a
solution to the .Connects problem.

It's always a good idea to minimize the amount of code written out,
thank you.
  #18  
Old February 25th, 2009, 11:42 PM posted to microsoft.public.visio.general
Barb Way
external usenet poster
 
Posts: 190
Default ".Connects" member

I created a small drawing (two shapes connected by one connector) and ran
your sample against it. Actually, I updated it a little :
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
Debug.Print vsoSelect.Count

For Each vsoShape In vsoSelect
Debug.Print vsoShape.Name
Set vsoConnects = vsoShape.Connects
Debug.Print vsoConnects.Count
Next vsoShape

End Sub

The key here is that the info for vsoSelect.Count doesn't change, so I
pulled it out of the loop through the selection. Then I added a line to
print the shape name. Here is the output that I get :

3
Dynamic connector
2
Decision
0
Process
0

This makes sense, as there are 3 objects in the selection. Then we see the
name of each item, followed by the count of connections. The Dynamic
Connector is the only connector on the page, so it is to only non-zero
number, and it should be 2, since it connects to two shapes.

If you want to play with a great example of the use of Connects versus
FromConnects, I suggest installing the SDK (if you haven't already) and
searching the Visio Code Samples Library for "Drawing Navigator Using
Connections". There are samples for VB, VB.Net, and C#, and it is a great
demonstration of these properties, and how to 'walk' a drawing using the
connections information :

"Description:
This sample drops a set of shapes that are connected to each other in a
hierarchical fashion on a page and then walks through each shape from a
starting shape, using the begin and end points of the Dynamic connectors."

You are on the right track - try my version of your sample code in a simple
drawing, to see if you observe similar results to mine. Then you can test
out the Navigator sample to explore further.


Barb Way
Product Support - Visio
Microsoft Corporation
[This posting is provided "As Is" with no warranties, and confers no
rights.]
--------------------
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.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:48 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.