When you want to be able to move several shapes together as a unit, the simplest thing to do is group them: select the shapes, and then press Shift+Ctrl+G. When you want to ungroup a group, press Shift+Ctrl+U. (Or use the commands on the Shape, Grouping menu.) That might be all you need to know about groups. However, Visio groups are actually quite smart, meaning they have editing and behavior options that you can control. Moreover, many Visio shapes are groups, as Figure 22-22 shows, and these groups have been designed with special behavior that affects the way you select and format them. So if you want to know savvy techniques for revising existing groups, or all the ways to create and control your own groups, read on.
Figure 22-22. Many Visio master shapes are groups. These master shapes were made by grouping several differently formatted shapes to create a single, easy-to-use object.
Because a group is an object, it can include attributes that are independent of the shapes in the group. For this reason, you might want to create a group in the following situations:
There are also programmatic reasons for creating a group. When you group shapes, references to the group are inserted into each shape's ShapeSheet. You can define shape formulas for each shape as well as for the group, and you can make the shape and group formulas interdependent. For example, a shape formula can specify unique sizing behavior as a function of the group size. When you ungroup shapes, the group's ShapeSheet is discarded, which breaks any custom formulas that refer to the group.
Visio displays a message when ungrouping.
When you ungroup certain shapes that came from a Visio stencil, the following message appears:
The explanation for this message is rather technical, but the short answer is to click OK if you're really sure you want to ungroup the object.
Here's the long answer: every time you drag a master shape from a stencil onto the drawing page, you create an instance of the master. The instance—that is, the shape you see on the drawing page—remains linked to its master and inherits formulas from the master. That way, if you have 100 instances of the same master in a diagram, which could easily happen in a diagram such as an organization chart, the formulas used to create that shape are stored in only one place, which makes for smaller file sizes. When you ungroup a group, you're destroying the object (the group) that is linked to the master. If that object no longer exists, Visio obviously can't link it to anything, and so the warning message appears.
It's easy to confuse groups and merged shapes, those complex shapes that result from using a shape operation command. To verify that a shape is really a group, select the shape, and then choose Format, Special. If you see Group in the Type field, it's a group, as Figure 22-23 shows.
Here are some other ways to tell whether an object is a group:
Figure 22-23. One sure way to identify a group is to use the Format, Special command and inspect the Type field.
You can subselect a shape in a group by double-clicking it, and then move or format the shape while retaining its group membership. When you subselect a shape, the selection handles have small ×s, as Figure 22-24 shows. If the shape is locked, padlock handles appear instead, and you might not be able to format or reposition the shape depending on the type of lock that's been set.
You can add a shape to or remove one from an existing group with a single command, so you don't have to ungroup and regroup. Table 22-2 summarizes how to edit shapes in a group.
Table 22-2. Techniques for Editing Shapes in a Group
Edit shapes in a group
Select the group, and then click a shape in the group to subselect it. Format or move the subselected shape or its text.
Add a shape to a group
Select the shape and the group, and then choose Shape, Grouping, Add To Group.
Remove a shape from a group
Subselect the shape you want to remove from the group, and then choose Shape, Grouping, Remove From Group.
Figure 22-24. Depending on a group's behavior settings, you can subselect an individual shape that is a member of a group to edit or move it.
What if you can't subselect a shape in a group? Some Visio groups are set to prevent subselection, but you can reset this option as follows:
For details about the behavior options for groups, see "Controlling Shape Behavior in Groups."
When you subselect a shape in a group, you can't reposition the shape.
Tucked into a group's ShapeSheet spreadsheet is an option that prevents you from moving the group's component shapes, or "children" as the option refers to them. The only way to reset this option is to edit the group's ShapeSheet settings as follows:
If you edit the groups that come with Visio stencils, you will probably encounter the message shown in Figure 22-25. Visio displays this message when a group is locked to prevent ungrouping.
Figure 22-25. When a group is locked, this message appears when you try to ungroup it.
Group behavior and protection options can be set to prevent you from taking certain actions, but these protections are designed to make the group work the way you expect (or the way the shape designers think you expect it to work). Protection settings prevent you from accidentally resetting any SmartShapes formulas the group might include. For example, the 3-D Box shape on the Blocks stencil is a group with a control handle that lets you adjust the box's depth. The shape is locked so that you can't ungroup it, because doing so would remove the control handle's built-in behavior. This option to lock a group is found only in the ShapeSheet window, so to change the lock, you must edit the group's ShapeSheet settings.
Follow these steps to unlock a locked group:
You have now changed the value of the LockGroup cell from 1 (or true, meaning that the group is locked) to 0 (or false, meaning that it's no longer locked). Now you can close the ShapeSheet window and ungroup the group by pressing Shift+Ctrl+U.
Often, a shape in a group will be locked against moving or resizing. When you subselect a locked shape in the group, padlock handles appear around the shape, and you can't resize it. For example, the lid of the Scanner shape is locked to prevent you from changing its width and height or from rotating or deleting it, as Figure 22-26 shows.
Figure 22-26. When you select a group and see padlock handles, it's your clue that protection locks have been set. To change the locks, choose Format, Protection.
Follow these steps to unlock a shape in a group:
Sometimes it's easier to edit grouped shapes when you work in the group window, in which Visio displays a group as if it were an entire drawing of independent shapes, as Figure 22-27 shows. The shapes are not rotated in the group window even if the group is rotated on the drawing page, so you can more easily align shapes with the grid, guides, and rulers. You can select and edit the shapes individually in the group window by using the same menus and tools as in the drawing window. As you make changes in the group window, the group is updated immediately on the main drawing page.
Figure 22-27. You can switch between the group window and the main drawing page by clicking the title bar of the window in which you want to work.
Follow these steps to display a group in the group window:
For a group, the alignment box is the selection rectangle that usually surrounds the group tightly. If you reposition the shapes in a group, however, the alignment box's
dimensions might not match the group. You can quickly reset its size to fit the group's new dimensions.
Follow these steps to reset an alignment box:
If you want to know why a Visio-made group acts the way it does, or if you want to design your own groups, you can investigate the group behavior options. Group behavior includes the way shapes in a group are resized when a group is resized, the order in which shapes can be subselected in a group and whether they can be subselected, and other rather esoteric options designed with professional shape programmers in mind.
To define the behavior for a group, select the group, and then choose Format, Behavior. The Behavior tab of the Behavior dialog box includes options that apply to groups, as Figure 22-28 shows.
Figure 22-28. The Group Behavior settings in the Behavior dialog box are available only when you select a group.
The sections that follow tell you which options to use, and when.
The Resize Behavior options are useful when you're working with shapes that represent real-world objects. You probably wouldn't need these settings in a flowchart, but an office layout is another matter. The classic example used in Visio documentation is a kitchen countertop with appliances. You can group the appliances and countertop so that you can move them around as a unit in your house plan. You can even resize the group because you want the countertop to be longer. However, you wouldn't want the shapes in the group—the stove and sink—to stretch out of proportion. They represent industry-standard sizes. Table 22-3 describes the options.
Table 22-3. Resize Shape Behavior Options for Groups
Scale With Group
This setting means that shapes are sized proportionally when the group is resized.
This option specifies that the shapes are repositioned as the group is resized; the individual shapes do not change in size (as in the kitchen countertop and appliances example).
Use Group's Setting
This option is the default for most Visio shapes and specifies that the shape will behave as the group is set to do when resized.
Among the intriguing things you can do with groups is specify whether new shapes
can be added to a group, and how. You can quickly add a shape to an existing group
by selecting both the shape and group, and then choosing Shape, Grouping, Add To Group. However, you can set a behavior option that allows you to drag shapes onto a group to become part of the group. You can also prevent this behavior. Table 22-4 describes the options in the Behavior dialog box for controlling group membership.
Table 22-4. Add Shape Behavior Options for Groups
Add Shape To Groups On Drop
When selected, this option lets you drag a shape or group on top of another group to make it a member of the group. For this to work, though, the group you're adding to must have the Accept Dropped Shapes option selected. This option appears in the Miscellaneous section.
Accept Dropped Shapes
When selected, this option allows a group to accept as a member a shape or group that you drag on top of it, provided that the Add Shape To Groups On Drop option has been selected for the prospective member shape. This option appears in the Group Behavior section.
When you click a group, what happens? The Behavior dialog box provides options that let you determine the answer to this question. Most of the time, when you click a group, the group is selected. You click again, and one of the shapes in the group is subselected. However, selection behavior doesn't have to work this way. Some Visio groups are set so that you can't subselect the component shapes. For example, the Bridge shape on the Roads stencil includes this behavior, because the group doesn't contain any shapes you're likely to want to edit. Table 22-5 describes the options in the Behavior dialog box that control how groups and shapes are selected.
Table 22-5. Selection Behavior Options for Groups
When selected, this option means that no matter how many times you click a group, you'll select only the group. You cannot subselect shapes in the group. If you clear this check box, you can subselect the group's shapes.
When selected, this option specifies that the first time you click a group, the group is selected. The second click selects the shape you're pointing to. This is the behavior you encounter most of the time with Visio shapes.
When selected, this option specifies that the first time you click a group, the shape you're pointing to is selected. The second click selects the group if you're pointing to the group's bounding box; otherwise, the text insertion point appears in the shape. This setting is useful when the priority is access to the shapes in a group.
Because a group is an object, it has properties, including text, that are independent of the shapes in the group. Visio shape designers often take advantage of this fact to create master shapes that are easy to type in. For example, most network equipment shapes are groups that include a label. To make sure the label displays properly, the group is set so that its text box appears in front of the other shapes in the group. Table 22-6 summarizes the options for controlling the display of group attributes, such as text.
Table 22-6. Group Behavior Options
Edit Text Of Group
This check box lets you control whether or not you can edit the text of a group.
This option in the Group Data list hides a group's text. You can type in a group for which this option is selected, but the text won't appear on the screen. The text is stored with the group and reappears if you choose a different behavior. This option makes it easier to type in shapes with multiple text boxes and makes it more likely that the text will end up in the right place. The Hide option does not hide a group's connection points or control handles.
Behind Member Shapes
This option in the Group Data list places the group's text behind the other shapes in the group.
In Front Of Member Shapes
This option in the Group Data list is the default used by most Visio shapes and places the group's text in front of the shapes in the group.
Some groups are designed to be connected to other shapes. For example, a door in an office layout is a group that you can connect to a wall, which is another group. When you create a group, you can control whether the component shapes in the group can be connected to other shapes or just the group. The default behavior for Visio groups is to enable snapping and glue for the component shapes, but, as in the case of the door and wall shapes, that may not be the behavior you want.
In the Behavior dialog box, the Snap To Member Shapes check box controls group snapping and gluing behavior. When this option is selected, you can connect the shapes in a group to other shapes, and the shapes' connection points are visible. By clearing this check box, you ensure that connectors and other shapes can be glued to the whole group only. Connection points on the group's component shapes are hidden.