Selecting subshapes

D

dani

Hi all,

is it possible to directly select a subshape of a group, or do I have to
select the group first and then iterate down to the desired shape and
doing a subselect on all of them?

Daniel
 
D

Digitall

Format>Behavior, In Behavior window: Behavior>Group
behavior>Selection>Members first.
 
D

dani

thanks, but I forgot to write in my previous post that I need to do that
by automation...

Daniel
 
M

Markus Breugst

Hi Daniel,

if you know the NameID of your sub-shapes then it's no problem to get a
reference directly.
In the following example VB function, "Sheet.3" is a group shape, and
"Sheet.2" as well as "Sheet.1" are sub shapes of this group.

Best regards,
Markus

Public Sub test()
Dim myShape As Shape
Dim myText As String
Set myShape = ThisDocument.Pages(1).Shapes("Sheet.3")
myText = myShape.Text
Set myShape = ThisDocument.Pages(1).Shapes("Sheet.2")
myText = myShape.Text
Set myShape = ThisDocument.Pages(1).Shapes("Sheet.1")
myText = myShape.Text
End Sub
 
D

dani

Hi Markus,

thanks... I didn't know this works... but still, i need to subselect the
subshape.
For now I have a routine which gives me the parent of the shape, then I
select the parent, and then I subselect the subshape.

Daniel

Directly subselecting a subshape didn't work...
 
M

Markus Breugst

Hi Daniel,

here's another example. "Sheet.1" is a shape inside a group. The procedure
selects this shape. You have to use "visSubSelect" as selection parameter.
The value "visSelect" does not work for subshapes and causes an error
message.

Best regards,
Markus

Public Sub SubSelect()
Dim myShape As Shape
Set myShape = ThisDocument.Pages(1).Shapes("Sheet.1")
ActiveWindow.Select myShape, Visio.visSubSelect
End Sub
 
D

dani

Hi Markus

thanks for your efforts. But the example you gave me is only working
when the group is already selected, otherwise, I get an error.

But I've programmed a workaround... I first select the group by
accessing the parent shape, and then subselect the subshape.

Maybe it just doesn't run in my version of Visio (2002 Pro), it's acting
weird anyway lately... it takes me more than a minute to save a new
document, no matter how large it is...

Sincerely,
Daniel
 
M

Markus Breugst

Hi again, Daniel.
Maybe it just doesn't run in my version of Visio (2002 Pro), ...

That's it. I did not select the group first, BUT I used Visio 2003 for the
test and it worked. Now after receiving your last mail, I did the test with
Visio 2002, and you're right: With this verion it only works when the group
is selected previously. Hovewer, good to hear that you found a workaround.

Best regards,
Markus
 
A

Abraham Mathew [MSFT]

A grouped shape has a Shapes collection which will allow you to access
sub-shape like this:
ActivePage.Shapes("Sheet.5").Shapes("Sheet.2")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top