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  

Using Selection



 
 
Thread Tools Display Modes
  #11  
Old January 16th, 2009, 02:03 AM posted to microsoft.public.visio.general
Paul Herber
external usenet poster
 
Posts: 1,732
Default Using Selection

On Fri, 16 Jan 2009 01:01:03 +0000, Paul Herber
wrote:

On Thu, 15 Jan 2009 10:31:07 -0800 (PST), Sachin
wrote:

the connects belong to a shape


Exactly.

The connections belong to a shape, the shape belongs to a selection. I
need to get the connections of a selection, so to do so I used the
bridge


No such thing as a bridge.
Look at the code John has posted
1. create a reference to the selection
2. this selection contains selection.count shapes
3. loop though these shapes using for each
4. with each shape get the connects


oh, and it can get more complicated, it depends upon the shapes, if a
shape is a group and the connection is to a shape within the group
then you will have to loop through these shapes as well, and grouping
can go to any level.


--
Regards, Paul Herber, Sandrila Ltd.
DFD/SSADM for Visio http://www.visio-dfd.sandrila.co.uk/
  #12  
Old January 16th, 2009, 02:32 AM posted to microsoft.public.visio.general
John... Visio MVP
external usenet poster
 
Posts: 900
Default Using Selection

"Paul Herber" wrote in message
ell.net...
On Thu, 15 Jan 2009 10:31:07 -0800 (PST), Sachin
wrote:

the connects belong to a shape


Exactly.

The connections belong to a shape, the shape belongs to a selection. I
need to get the connections of a selection, so to do so I used the
bridge


No such thing as a bridge.
Look at the code John has posted
1. create a reference to the selection
2. this selection contains selection.count shapes
3. loop though these shapes using for each
4. with each shape get the connects


--
Regards, Paul Herber, Sandrila Ltd.
DFD/SSADM for Visio http://www.visio-dfd.sandrila.co.uk/



You need to check FromConnects as well.
BoxA -- Dynamic Connector -- Box B
will only show entries in the Dynamic Connector Collection. One to Box A and
One to Box B
The FromConnects of BoxA and BoxB will show the reverse of those two
connections.

John... Visio MVP

  #13  
Old January 16th, 2009, 04:15 PM posted to microsoft.public.visio.general
Sachin[_2_]
external usenet poster
 
Posts: 15
Default Using Selection

Wow. That is very helpful. Thanks a lot, both of you!
  #14  
Old February 4th, 2009, 09:49 PM posted to microsoft.public.visio.general
Sachin[_2_]
external usenet poster
 
Posts: 15
Default Using Selection

Hi again.

I had this piece of code working, but when I tried it with a different
drawing (exact same piece of code), the macro would run but no matter
what it would give me the message box saying I needed something
selected. I have tried selecting single shapes, different shapes,
multiple shapes, everything. I have re-entered the code, looked over
it and everything is the same and looks fine. Does anyone know what
might be causing this?

Thanks in advance, Sachin.
  #15  
Old February 4th, 2009, 10:25 PM posted to microsoft.public.visio.general
Dieter Sternberg
external usenet poster
 
Posts: 8
Default Using Selection

If you have something selected and the Selection.Count is zero (or less
than the expected size) you may have shapes selected within a group.
In this case playing with Selection.IterationMode can help.
Set it to visSelModeSkipSuper for example and see if Selection.Count
changes.

Regards
Dieter


Sachin wrote:
...
what it would give me the message box saying I needed something
selected.
...
Thanks in advance, Sachin.

  #16  
Old February 5th, 2009, 01:31 AM posted to microsoft.public.visio.general
John... Visio MVP
external usenet poster
 
Posts: 900
Default Using Selection

"Sachin" wrote in message
...
Hi again.

I had this piece of code working, but when I tried it with a different
drawing (exact same piece of code), the macro would run but no matter
what it would give me the message box saying I needed something
selected. I have tried selecting single shapes, different shapes,
multiple shapes, everything. I have re-entered the code, looked over
it and everything is the same and looks fine. Does anyone know what
might be causing this?

Thanks in advance, Sachin.



Post the code so we can take a look at it.

John... Visio MVP

  #17  
Old February 5th, 2009, 11:28 AM posted to microsoft.public.visio.general
Paul Herber
external usenet poster
 
Posts: 1,732
Default Using Selection

On Wed, 4 Feb 2009 12:49:07 -0800 (PST), Sachin
wrote:

Hi again.

I had this piece of code working, but when I tried it with a different
drawing (exact same piece of code), the macro would run but no matter
what it would give me the message box saying I needed something
selected. I have tried selecting single shapes, different shapes,
multiple shapes, everything. I have re-entered the code, looked over
it and everything is the same and looks fine. Does anyone know what
might be causing this?


Well, one of your previous posts said " ... I am hard coding for one
shape only for simplicity and to avoid confusion."
Is this still the case?


--

Regards, Paul Herber, Sandrila Ltd.
Electronics for Visio http://www.electronics.sandrila.co.uk/
  #18  
Old February 5th, 2009, 02: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.


  #19  
Old February 5th, 2009, 06:48 PM posted to microsoft.public.visio.general
John... Visio MVP
external usenet poster
 
Posts: 900
Default Using Selection

Looks like you are suffering from email word wrap.
The lines with ".Name" are part of the Debug.print line before them. Remove
the carriage return at the end ofthe previous line and you should be fine.

It appears the newsgroup posting split the line into two lines and VBA just
does not understand the second line.

John... Visio MVP

"Sachin" wrote in message
...
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.




  #20  
Old February 5th, 2009, 08:22 PM posted to microsoft.public.visio.general
[email protected]
external usenet poster
 
Posts: 32
Default Using Selection

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
 




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 08:46 PM.


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