Word of Law No. 27 – Columns, Mice, Keys – Aha!

[Originally appeared 2000.]

Somehow I imagined as I finished the Word of Law column in Word of Law No. 26 that it would be straightforward to finish the explanation of Word 2000’s Table AutoFit functions and offer some final guidance on avoiding “strange” table formatting. After a workshop on Word 2000 table functions and issues with the Word transition team at a law firm, I can offer some fresh insights and still won’t finish the story.

Before reading further, please understand that the intricacies described here are intended primarily for master users and developers. For general users, organizations should construct sample tables with the intricate formatting resolved, as has been encouraged in the last several Word of Law columns. For those working without such support, please consider thisa warning that discovery and mastery of table formatting techniques is not a wise task when trying to complete a document under a deadline. While practicing these techniques, it is safest to work on a document other than “real” production work.

Let’s return to the “strange” column widths mentioned in Word of Law No. 26. The most frequent symptom is a table with a ragged right border, some rows longer than others. Ragged right borders result if column widths are changed or columns inserted or deleted after one or more cells in at least one column of a table have a width different from other cells in the same column. This can occur either by changing the size of some cells directly, or by splitting one or a group of cells into multiple columns without applying that change to the entire column.

In both Word 97 and Word 2000, column widths can be set by dragging the column marker on the Ruler (the shaded bar with a tool tip of “Move Table Column”), by dragging a table border (enabled when the mouse cursor shifts to a double vertical bar with arrows pointing both right and left) and through the Column tab of the Cell Height and Width dialog (Word 97) or the Table Properties dialog (Word 2000). Very interesting things occur when the SHIFT, CTRL and ALT keys are combined with the use of the mouse and the Ruler. Holding down the ALT key while dragging either the column marker on the Ruler or the table border changes the ruler to show the column widths as the marker or border is dragged.

The follow situations occur if no cells have been selected before trying to change a column width:

•           Drag a column marker in the Ruler without SHIFT or CTRL pressed: The column immediately to the left and to the right of the marker increases or decreases in width, without changing the size of the columns to the right. The right edge of the table moves with the change, possibly beyond the right margin of the page.

•           Drag a table border without SHIFT or CTRL pressed: The width of the column immediately to the left and to the right of the border changes, but all other columns remain unchanged in width. The right edge of the table does not change.

•           Drag the column marker with SHIFT pressed, but not CTRL: The width of the column immediately to the left and to the right of the marker changes, but all other columns remain unchanged in width. The right edge of the table does not change. (Yes, this is the same as dragging the table border without SHIFT or CTRL pressed.)

•           Drag the table border of the selected cell with SHIFT pressed: The column immediately to the left and to the right of the marker increases or decreases in width, without changing the size of the columns to the right. The right edge of the table moves with the change, possibly beyond the right margin of the page. (Yes, this is the same as dragging the column marker without SHIFT or CTRL pressed.)

•           Drag the column marker or table border with CTRL pressed: The width of the column and the width of the columns to the right change proportionally. The right edge of the table does not change.

Before we get any further, then, notice that the Ruler behavior indicates what will happen to all of the columns before the change is applied to the table. In all cases, holding the ALT key down while dragging will show the column widths in the ruler.

We can understand these functions even better by looking at the controls VBA provides for setting column width. Although the language of VBA is most familiar to developers, the capabilities revealed by VBA can help others understand table behavior more thoroughly. The SetWidth Method is the VBA tool that allows a column or cell width to be changed. It includes a setting called “RulerStyle” that has four constants:

wdAdjustFirstColumn – The column in which the cursor lies and changes size, as does the column immediately to its right. The remainder of the columns remain the same size and the right edge of the table stays still.

wdAdjustNone – The column or selected columns change size to the stated value, and the remainder of the columns to the right keep their size. The right edge moves left or right accordingly.

wdAdjustProportional – Columns to the right of the selected columns are changed proportionally.

wdAdjustSameWidth – The selected column is adjusted to the set figure, but columns to the right are adjusted to equal width, leaving the right edge of the table still.

Now, with these capabilities stated (I hesitate to write “understood” <g>), we can return to the case where some cells in a column differ in width from other cells in that column. First, to cause this to happen (let’s assume intentionally), select the specific cell or cells first before changing the width by dragging the column marker or the table border. The following occurs:

•           Drag the column marker in the Ruler without SHIFT or CTRL pressed: The selected cell increases or decreases in width, without changing the size of the columns to the right. The remainder of the column in which the cells were selected retains its old width. The right edge of the table becomes ragged. This is the wdAdjustNone behavior.

•           Drag the table border of the selected cell without SHIFT or CTRL pressed: The width of the selected cell and the cell to the other side of the selected border change, but all other columns remain unchanged in width. The right edge of the table does not change and there is no ragged border. This is the wdAdjustFirstColumn behavior.

•           Drag the column marker with SHIFT pressed: This is the same as dragging the table border without SHIFT or CTRL pressed.

•           Drag the table border of the selected cell with SHIFT pressed: This is the same as dragging the column marker without SHIFT or CTRL pressed.

•           Drag the column marker or table border with CTRL pressed: The width of the selected cell changes and the width of the cells to the right change proportionally. The right edge of the table does not change. This is the wdAdjustProportional behavior.

All of the Ruler, mouse controls and VBA commands described above operate both in Word 97 and Word 2000. Changes to Word 2000 tables made with these Ruler and mouse techniques or VBA commands will function properly in Word 97, assuming no other table features (including Table AutoFit) have been used.

The primary difference between Word 97 and Word 2000 for the behaviors described so far is the difference between the Cell Height and Width dialog in Word 97 and the Table Properties dialog in Word 2000. In the latter, the column width controls are presented on the Column tab of that dialog. It introduces a “Preferred Width” setting, which works with both regular column widths and the automated column widths of the Table AutoFit function.

What is missing in both of these dialogs is a way to access the SetWidth functions described above. It is possible to construct a dialog that allows the cell or column width to be set and select one of the behaviors.

Next time we need to look at what happens when columns are inserted when one or more cells differ in width from their column, and return to Table AutoFit.

This 2000 article originally appeared in Office Watch.Subscribe to Office Watch free at http://www.office-watch.com/.