Need Help handling shapes in a group

T

TooTall

I am new to Visio VBA and cannot figure this out. I've looked at all of the
examples.

I have a macro that executes on double-click. I want to take the Selection
(selected object) rotate it 180, flip it, and turn on a fill pattern to
indicate its 'backside'. It only works for a simple single shape, and I am
beating my head against the wall trying to figure out how to handle a group
of shapes. I think that to 'fill' the shapes I must first ungroup and then
handle each shape separately, then regroup. How the heck do I do this?

Also, FillPatternKeepFmt wants a string, but the shapesheet only shows the
number. Where can I find a defintion of these strings???

Thanks in advance.
 
M

Mark Nelson [MS]

Are you using Visio 2003? The code will be different than in 2002. Visio
2003 has several methods on the Selection object that let you perform flip &
rotate. You can choose whether to treat all selected shapes as a single
unit or separately. (Visio 2002 only operates on shapes separately.)

You can iterate through the selected shapes by using Selection.Item(n).
This is necessary to set formatting properties such as a fill pattern.
 
T

TooTall

Thanks Mark,

I am using VIsio Pro 2000.

Do I have to ungroup and then regroup afterwards?

The rotate and flip are working fine, I am only having problems with
handling the group aspects, and finding the right strings to set the fill
pattern.
 
M

Mark Nelson [MS]

If I understand your problem, some of the shapes you want to set the fill
pattern for are group shapes. The Visio user interface and automation
interface behave differently when it comes to formatting of groups. In the
UI any formatting applied to a group shape is automatically applied to every
sub-shape within the group. In the API you must manually change the
formatting on any sub-shapes you want.

You can check the Shape.Type property to find out if a shape is a group. If
so, use the Shape.Shapes collection to iterate through the sub-shapes. Set
the FillPattern cell on each sub-shape. Since groups can be nested, you
would need a recursive routine (or similar method) to walk through the
sub-shapes of each group.

--
Mark Nelson
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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