How to tell is a shape is a group

A

Aussie Susan

I need to manipulate a shape, basically by converting it to a group and then
adding the sub-shapes. However, if the top level shape is already a group,
then I need to do some clean-up operations first.

How do I tell is the shape is already a group fom within VBA (other than
using the ON ERROR mechanism around the 'ConvertToGroup' method)?

VISIO itself seems to be able to tell if a shape is a group or not in that
it changes the icon in the 'Drawing Explorer' window, and includes/excludes
the 'Group Properties' shapesheet section. However, the
VisSectionObject/VisRowGroup row seems to exist whether or not the shape is a
group. I'm sure that there must be a proper way of doing this!

Thanks

Susan
 
P

Paul Herber

I need to manipulate a shape, basically by converting it to a group and then
adding the sub-shapes. However, if the top level shape is already a group,
then I need to do some clean-up operations first.

How do I tell is the shape is already a group fom within VBA (other than
using the ON ERROR mechanism around the 'ConvertToGroup' method)?

VISIO itself seems to be able to tell if a shape is a group or not in that
it changes the icon in the 'Drawing Explorer' window, and includes/excludes
the 'Group Properties' shapesheet section. However, the
VisSectionObject/VisRowGroup row seems to exist whether or not the shape is a
group. I'm sure that there must be a proper way of doing this!

assuming the shape is referenced as shpObj then if
shpObj.shapes.count > 0
it is a group.
 
A

Aussie Susan

Paul,

I have tried that, but the sequence:

1) create a shape (say a rectangle)
2) Use the 'Shape _> Grouping -> Convert to Group' menu option
2) set shpObj to reference it in VBA
3) look at shpObj.Shapes.Count

shows that the shape has 0 sub-shapes. However, the shape is still a group
but without any sub-shapes.

Unfortunately, in my case, this combination (a group shape that does not yet
have sub-shapes) is possible.

Thanks

Susan
 
D

David Parker

Try:

If shpObj.Type = Visio.VisShapeTypes.visTypeGroup Then
.....

(Visio.VisShapeTypes.visTypeGroup = 2)
 
P

Paul Herber

Yes, of course!
However, most of the time the shapes.count is far more useful. A
grouped shape still behaves like a shape and its shapesheet is the
same as a non-grouped shape, it's only its shapes.count that tells you
that there are subshapes.
 

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