Sei sulla pagina 1di 78

MVP TABLES

Tables and table-related fields


Table basics

Why don't my table borders print?

Run for the border: using borders in Word

The strait and narrow: using columns

Keeping a table together on one page

How do I control where the page breaks will fall in a table which extends over several
pages?

Or: if I insert a manual page break, then my table heading is not repeated on the next page

Or: I added an extra row to my table, and suddenly, all but the first row jumped to the next
page

Maximising the performance of Word tables

How can I resize a table to fit the page's width?

How to centre a left-justified table (or left or right-justify a centred one)

How to fix the Word 2000+ Cell Alignment buttons

How to sidestep the problems of the Word 2000 (and higher) Table Properties dialog

Is there a way to add custom table formats to the Table Autoformat list?

I tried to use the { =SUM(ABOVE) } formula in a table but the answer was obviously
incorrect

How to get a formula field to total an entire table column, even if some cells in the column
contain text or are blank

Floating objects in Word 2000 table cells are vertically aligned wrongly
Whenever I insert a graphical object (picture, drawing object, etc.) into a Word 2000 table cell I
lose the vertical formatting. The text is always aligned at the top of the cell, instead of being
centered or at the bottom of the cell. Why, and what can I do about it?

I have a “Name” column which I want to split into “FirstName”, “LastName” – how can I do
it?

How to convert a Word table into an Access database

How to use relative cell references in Word table formulas

How to link a Word table with a Word graph

See also the “Tables” section on the Macros/VBA tab

2
3
Tables and table-related fields ............................................................................... 2
Table Basics ........................................................................................................................ 6
Overview ......................................................................................................................... 6
What is a Table?.............................................................................................................. 7
Inserting a table ............................................................................................................... 8
Working in a table ........................................................................................................... 9
Tabs ............................................................................................................................. 9
Selecting text ............................................................................................................. 10
Margins and indents .................................................................................................. 10
Selecting parts of a table ............................................................................................... 10
Sizing rows and columns .............................................................................................. 11
Sizing columns using the ruler .................................................................................. 11
Sizing columns using the cell borders ...................................................................... 12
Another way to size columns and rows .................................................................... 12
Even distribution ....................................................................................................... 13
Adding rows or columns ............................................................................................... 13
Deleting rows, columns and tables ............................................................................... 13
Repeating headings ....................................................................................................... 14
Positioning the table...................................................................................................... 14
Controlling text flow ..................................................................................................... 14
“Widow/Orphan control” and “Keep lines together” ............................................... 14
“Keep with next”....................................................................................................... 14
“Page break before” .................................................................................................. 15
Performance issues........................................................................................................ 15
Advanced techniques .................................................................................................... 15
Merging cells ............................................................................................................ 15
Vertical alignment ..................................................................................................... 15
Text direction ............................................................................................................ 16
Cell margins .............................................................................................................. 16
Graphics in tables ...................................................................................................... 17
Nested tables ............................................................................................................. 17
“Text-wrapped” tables and frames............................................................................ 18
Tables and HTML ..................................................................................................... 19
Drawing tables .......................................................................................................... 19
Wide tables.................................................................................................................... 19
Narrow tables ................................................................................................................ 20
Changing your mind ..................................................................................................... 20
Why don't my table borders print? .................................................................................... 22
Run for the border: using borders in Word ....................................................................... 24
Borders, boundaries, gridlines ...................................................................................... 24
Access to borders .......................................................................................................... 24
Some “gotchas” ............................................................................................................. 28
Some disadvantages of using the Tables and Borders toolbar ...................................... 29
Drawing tables .............................................................................................................. 29
The strait and narrow: using columns ............................................................................... 32

4
Types of columns (tables, snaking columns, or ??) ...................................................... 32
Tabs ........................................................................................................................... 32
Tables ........................................................................................................................ 32
Text box columns...................................................................................................... 32
Snaking columns ....................................................................................................... 33
Parallel columns ........................................................................................................ 33
How many columns?..................................................................................................... 33
Getting started ............................................................................................................... 33
Planning your columns ............................................................................................. 33
What you will see...................................................................................................... 34
Completing the setup ................................................................................................ 34
Working with snaking columns .................................................................................... 34
Multicolumn sections in single-column documents ..................................................... 35
Some snaking column gotchas ...................................................................................... 35
Columns within columns .......................................................................................... 35
Footnotes ................................................................................................................... 35
Headers and footers................................................................................................... 36
Headings spanning columns ..................................................................................... 36
Summary ....................................................................................................................... 37
Keeping a table together on one page ............................................................................... 38
Maximising the performance of Word tables ................................................................... 41
As a user ........................................................................................................................ 41
In code ........................................................................................................................... 43
How can I resize a table to fit the page's width? ............................................................... 50
Word 2000 .................................................................................................................... 50
Word 97 ........................................................................................................................ 50
How to centre a left-justified table (or left or right-justify a centred one) ....................... 53
How to fix the Word 2000+ Cell Alignment buttons ....................................................... 55
Is there a way to add custom table formats to the Table Autoformat list? ....................... 58
I tried to use the { =SUM(ABOVE) } formula in a table but the answer was obviously
incorrect ............................................................................................................................ 59
How to get a formula field to total an entire table column, even if some cells in the
column contain text or are blank ....................................................................................... 62
Floating objects in Word 2000 table cells are vertically aligned wrongly ....................... 65
I have a “Name” column which I want to split into “FirstName”, “LastName” – how can
I do it? ............................................................................................................................... 66
How to convert a Word table into an Access database ..................................................... 69
Using Excel to transfer data between Word and Access: ............................................. 69
Using Word Only .......................................................................................................... 69
How to link a Word table with a Word graph ................................................................... 75

5
Table Basics

Article contributed by Suzanne Barnhill and Dave Rado

1. Overview 9. Repeating headings

2. What is a Table? 10. Positioning the table

3. Inserting a table 11. Controlling text flow

4. Working in a table 12. Performance Issues

5. Selecting parts of a table 13. Advanced techniques


6. Sizing rows and columns 14. Wide tables
7. Adding rows or columns 15. Narrow tables

8. Deleting rows, columns and tables 16. Changing your mind

To return to top, press Ctrl+Home, or use Alt + Left Arrow to Go Back)

Overview
If you come to Word from a typewriter background, you are probably used to setting up tabular
material using tabs. The very word tab is short for “tabulator,” and “tabulator” stops on a typewriter
are used in “tabulation,” that is, making tables. So your first impulse when you need to make a
table in Word may be to use tabs.

Sometimes this is an acceptable (or occasionally, even the best) way to go. For a simple table with
short entries, and very few rows, setting tab stops can be quick and easy, and Word allows you to
drag them around until the text lines up where you want it. If you do use tabs to create a “table”,
be sure you use them properly; in particular, never use the built-in tab stops; always create your
own. For tips on this subject, see Setting tabs (Or how to prevent tabbed paragraphs from
going all over the place when pasted between documents).

Like other word processors, however, Word offers a very easy way to create tables that use true
rows and columns, as opposed to simply containing tabular text. Whenever your needs are less
simple – for example, whenever the text in any column of your table might need to wrap to the next
line, or you need vertical table borders, or your table might span more than one page and need a
continuation header, or if you might ever conceivably need to change the column order – you

6
should use Word’s built-in Table feature. Note that you can convert tabular text into a Word Table
in one step, provided your tab stops were set properly, by selecting Table | Convert Text to Table
and pressing OK. See also Changing your mind.

Many people who are not familiar with using true Tables try to use text boxes to simulate the
appearance of a table with borders; or sometimes even to draw their borders using horizontal and
vertical drawing lines. As well as making life far more difficult than it need be during the design of
the table, this also creates a maintenance nightmare, should anyone need ever need to add,
delete or amend the data later, or to paste the table into another document. There is really no
circumstance in which using text boxes or drawing lines to create tabular information is ever
preferable to using a table.

Let’s look at what Word's Table feature does.

What is a Table?
How is a Table different from a “table” of tabbed text? As you know, you can arrange tabular
material using tabs. For example, you can use a combination of left-, center-, decimal-, and right-
aligned tab stops, in combination with horizontal paragraph borders, to create a text-based “table”
such as the following (shown with non-printing characters displayed, so you can see how it was
created):

Figure 1

Notice (in Figure 2) what can happen when you add some text to one of the lines, because of the
lack of support for word-wrapping:

Figure 2

Selecting a single “column” is possible (hold the Alt key down while you drag with the mouse); but
is much more difficult than if a Word Table had been used; and it is not possible to have a running
header, should the table span two pages.

But suppose the tabular material is more complex. For instance, suppose you have paragraph text
to be placed in side-by-side columns, as in the following example:

Comment, Statement, or Assertion Response or Rebuttal

7
Mr. Doe accepts the appraisal as “conform[ing] in most categories to R41b and the Standards of
Professional Practice in place at the date of the appraisal. It is not adequate for an appraisal to conform
“in most categories.” This is like saying that a driver generally follows traffic laws but will intentionally run
a red light or stop sign.

The report states: “I cannot render an opinion as to the accuracy of the valuation,” and “there are indications
that the value indicated in the report is reasonable.” This implies both that Mr. Doe agrees with the value
estimate and that there are or could be indications that the value indicated is not reasonable.
Figure 3

When you use tabs to create such a “table”, each “row” of the table (or sometimes the whole
table) is a single paragraph. If you tried to type text such as the above using tabs (and I have
actually seen this done!), you would have to break the paragraphs up into fragments that would fit
on each line. If the text had to be edited, it would be a nightmare. But when you use Word’s Table
feature to create a table, Word creates a “cell” for each intersection of a row and column. Each cell
contains a separate paragraph (or can contain several paragraphs); and the text in the cell can
wrap independently of the rest of the table. So whenever your tabular material contains text that
must wrap to the next line a Word table is far more satisfactory than a tabbed table.

Inserting a table
Inserting a table is easy.

If you choose Insert Table from the Table menu (or in Word 97, select Insert from the Table
menu), you can choose the number of rows and columns you want your table to start with. (Don't
ever select Table | Draw Table, for the reasons discussed below under Drawing tables.)

Or you can use the context-sensitive Table button on the Standard toolbar; when you click on this
you will see a flyout table grid on which you can use your mouse to select the desired number of
rows and columns.

Although the flyout (see Figure 5) shows five columns and four rows when you first click on it, you
can drag to select more rows and columns; the maximum number depends on your window size,
your screen resolution, and the relative placement of the button on your toolbar – that is, how far
you can drag before reaching the side or bottom of the Word window.
The number of columns is all that really matters because you can add rows to the table as you go: whenever you

press Tab at the end of the last row of the table a new row is created.

Figure 4: The Table button on the Standard toolbar is context-sensitive, its appearance and functionality being
determined by what is selected

8
For this reason I usually just create two rows, one
for the table headings and another for the first row of text. If applying grid borders, it's best to start
with three rows, so that you can apply one grid to row 1 and a separate grid to rows 2-3; but you
would almost never need to start with more than that.

When you first insert the table, it will have a ½-point border around the cells, creating a grid.
Figure 5: The Table button flyout
You can remove this, if desired, by selecting “None” in the Borders and Shading dialog, or using
the Tables and Borders toolbar, or the Borders button on the Formatting toolbar.

You may also be able to remove the border by pressing Ctrl+Alt+U, although in some versions
and languages of Word, this shortcut inserts a ú symbol instead (and there is no way of preventing
this from happening – it seems to be a bug). But if your installation of Word suffers from this
problem, you could get round this by assigning some other keyboard shortcut to the strangely
named command “TableUpdateAutoFormat”, which removes the borders; and then use your own
shortcut when you want to remove the borders.

In Word 2000 and above, you can also change Word's behaviour, so that when you first insert a
table, it will always be borderless. To do this, select Table | Insert Table; select the checkbox that
says “Set as default for new tables”; then click the AutoFormat button, de-select every checkbox
you see in the AutoFormat dialog; and click OK twice. From now on, all new tables will be inserted
without borders.

Even if you remove the border, you may still see faint lines between the table cells; these are
gridlines; they are just a (very important) visual aid, and do not print. If you do not see them, select
Table | Gridlines to turn their display on. For more on borders and gridlines see Why don't my
table borders print? and Run for the border: using borders in Word.

Working in a table
You can put almost anything in a table that you can put in normal document text, and you can
format table text the same way you would ordinary text paragraphs. The best way to do this, of
course, is with styles (you may want to define special styles for use in tables, and Word 2002 even
allows you to define special styles for an entire table), but you can apply font and paragraph
formatting the same way you normally do. There are just a few things that work differently in
tables.

Tabs
When you tab in a table, you go to the next cell (Shift+Tab takes you to the previous cell). This
makes it easy to work in tables because you don’t have to use the mouse to move your insertion
point. But you can still set tab stops in table cells; the trick is that you have to use Ctrl+Tab to tab
to them. The exception to this rule is the decimal tab. When you set a decimal tab stop in a cell,
the text aligns on it automatically (provided it is left-aligned or justified to begin with; any other

9
paragraph alignment gives very odd results).

Selecting text
If you’re used to selecting a line of text by clicking to the left of it or a paragraph by double-clicking
to the left of it, you’ll find that you can’t do this in a table. Whenever you point to a cell and click,
you select the entire cell. But you can still select text by dragging, and you can select a sentence
using Ctrl+click or a paragraph by triple-clicking in it. And if you normally select text using
keyboard shortcuts, these will still work.

Margins and indents


If you have the horizontal ruler displayed, you will see that it looks very different when you are
working in a table. Instead of seeing indent markers at the page margins, you will see them at the
sides of the space representing the table cell you are currently in. You can drag these as you
normally would to set paragraph indents. You will also see margin markers on the ruler,
representing the edge of each column – more on this later.

Figure 6: The ruler, when the selection is in a table

Selecting parts of a table


You can use the Select commands on the Table menu to select rows, columns, or the entire table,
but there are also mouse shortcuts for these tasks.

As mentioned earlier, if you point to a cell (the mouse pointer becomes a stubby black arrow
pointing northeast: ) and click, the entire cell is selected.

To select an entire row, point to it as you would a line of text (position the mouse pointer in the left
margin until it is a white arrow pointing northeast) and then click. Or point to any cell in the row and
double-click.

To select a column, hover the mouse over the top of the column until it becomes a stubby black
arrow pointing down. Click to select the column below it; then drag to select adjacent columns. You
can also select a column by clicking while pressing Alt anywhere in the column; and in long tables
this works much better, because you don't need to be at the top of the column to select it.

To select an entire table, with the insertion point anywhere in the table, press Alt and double-
click.

The introduction of the Research pane in Word 2003 has played havoc with the Alt + Click and Alt
+ Double-click shortcuts, because Alt + click is now the shortcut used to open the Research task
pane. An alternative for selecting a column is to hold Shift while clicking the right (or alternate)
mouse button.

To select the entire table, you can use the keyboard. Ensure that your keyboard Number Lock is
OFF, then press Alt + 5 on the number keypad (the "5" key in the centre of the number pad, not
the one above the letter "R").

If you do not use your number pad for entering numeric data, you can adjust your computer's
startup settings so that the NumLock key is turned off when your computer starts. See Enabling

10
the NumLock Key.

Unfortunately, if your keyboard does not have a numeric keypad, or you do not have access to it,
there is not, so far as we have discovered, an alternative mouse shortcut to select the entire table.
Double-clicking while pressing Alt will still select the table but will also open the Research pane. If
the Research pane doesn’t insist on trying to connect to the Internet, you may still find it easier to
Alt + double-click, close the task pane, and keep working than to work down through several
menu levels (Table | Select | Table).

In Word 2002 and above you can select non-contiguous rows and columns by pressing Ctrl while
selecting rows or columns after the first.

Sizing rows and columns


When you first insert a table, all the columns are the same size, and all the rows are an “Auto”
height that will accommodate the current text size. For example, if you are using the default Body
Text style, which uses the Normal font and has 6 pts Spacing After, then the table row will be high
enough for 10-pt (Word 97 and earlier) or 12-pt (Word 2000/2002) Times New Roman plus 6 pts
space following. (It's a good idea to define specific paragraph styles for use in tables that have
borders, with different spacing from your Normal style; such as 3 pts before and after.)

Because the row height is automatic, it will adjust to fit the amount of text you put into it, so you will
not ordinarily need to change this unless you need empty rows of a fixed height. But you probably
will need to change the width of the columns to accommodate the text they contain. In Word 2000
and 2002, you can let Word resize the columns for you (“AutoFit to contents”), but this can be very
disconcerting and not necessarily satisfactory. Furthermore, in Word 2000 and higher, the
“Automatically resize to fit contents” option under Table | Properties | Options slows tables down
dramatically, and it is a good idea to switch it off in all your tables (unfortunately, it is switched on
whenever you create a new table).

Most likely you will want to adjust the column widths manually. There are several ways to do this.

Sizing columns using the ruler


If you click and drag the area on the ruler that represents the space between cells, you change the
width of one or more of the cells. The way this change is made depends on how you drag, as
follows:

Simple click and drag: The cell to the left of the dragged border is made wider or narrower, and
the other cell widths are not changed (so the overall table width changes). Since the table is
initially inserted at margin width, this means that if you make one of the cells wider, the table will
extend beyond the right margin.

Ctrl+click and drag: The cell to the left is sized, and the difference is made up from the cells to
the right uniformly. That is, if you make the cell to the left larger, all the cells to the right become
proportionately smaller.

Shift+click and drag: The cell to the left is sized, and the difference in size is made up from the
cell to the right. That is, if you make the cell to the left larger, the cell to the right becomes
proportionately smaller.

Alt+click and drag: Same as simple click and drag except that the ruler displays the dimensions
of the cells as you drag, permitting finer adjustments.

However, note that the measurements the ruler displays are somewhat misleading, in that they do
not include the “Space between columns” (or cell margins).

11
For example, if you have a column of width 1" (2.54cm), and if the “Space between columns” is set
to 0.15", or 0.38cm, (the default), then the column width displayed on the ruler when you hold the
Alt key down will be 0.85" (2.16cm).

To find out the “Space between columns” setting using the Table Properties dialog in Word 2000
and higher, click the Options button on the Table tab, and add the Left and Right cell margin
measurements – although that isn't always accurate, as it only displays to two decimal places. For
instance, if the “Space between columns” is set to 0.15", the Left and Right cell margin
measurements on the Table Properties dialog both display as 0.08" instead of 0.075". A better way
of finding out the true measurements is covered at: How to sidestep the problems of the Word
2000 (and higher) Table Properties dialog.

Alt+Ctrl+click and drag: Same as Ctrl+click and drag except that the ruler displays dimensions.

Alt+Shift+click and drag: Same as Shift+click and drag except that the ruler displays dimensions.
(But see above rider.)

Sizing columns using the cell borders


You can also size the columns by dragging directly on the cell boundaries, and this is often much
easier than using the ruler – partly because the indent markers on the ruler can make it difficult to
get at the margin markers. Most people also find it more intuitive to drag the columns directly.

When you hover the mouse pointer over the gridline between two columns, it will change to a
double arrow (pointing right and left) with two upright parallel lines between it. When it has this

appearance, you can click and drag a column boundary.

You have the same six combinations as above, but, just to be totally confusing, simple click and
drag and Shift+click and drag (and Alt+click and drag and Alt+Shift+click and drag) are reversed in
their functionality.

It is possible that some users actually memorize or remember what these various combinations do,
but I personally just keep trying one after the other (with Undo in between) until I get the one that
does what I want!

Sizing rows
You can also adjust row height either using the vertical ruler or by dragging the cell boundaries, but
only in Page/Print Layout view.

Pressing Ctrl while you drag sets the row to an “Exact”, or fixed, height, so that if there is too
much text in the cell to fit, the surplus text will be hidden (setting exact row heights is particularly
useful for forms). If you don't use the Ctrl key, the row height is set to “At least” the measurement
you chose, so the row will expand in height if needed, to fit the text in the cell, but will not contract
below the minimum height you set.

Pressing Alt while you drag causes the ruler to display dimensions – but prevents you from setting
an Exact height, even with the Ctrl key held down.

Another way to size columns and rows


All versions of Word also have a dialog that allows you to set exact column widths and minimum or
exact row heights. In Word 97 and earlier, this is the Table | Cell Height and Width dialog, which
has Row and Column tabs. Row height is Auto by default but can also be set to “At least” or
“Exactly” a certain amount. By default this measurement is displayed in points, but you can type in

12
another measurement, followed by the measurement unit – such as 2" or 5 cm – and Word will
convert it to points.

Word 2000 and 2002 have a Table Properties dialog (accessible via the right-click shortcut menu)
that has Table, Row, Column, and Cell tabs. On the Table tab you can set a “preferred width” for
the entire table; this can be set in your default measurement unit (inches, centimetres, or whatever
else you have set on the General tab of Tools | Options), or you can set the “Measure in” drop-
down to “percent”, and set it to any percentage of the editable page width you wish. If you set it to
100%, it will always maintain full margin width, no more and no less (for coverage of the nearest
equivalent in Word 97, see: How can I resize a table to fit the page's width?).

On the Row tab of the Table Properties dialog, you can set “Auto,” “At least,” or “Exactly”
heights. On the Column tab you can set a “preferred” width for the current column, although
unfortunately, in Word 2000 and higher, “preferred” width does not mean actual width, and setting
the column width using the dialog usually gives unexpected results; dragging the columns to set
their widths is generally much more reliable. Fortunately, you can sidestep the unreliability of the
Word 2000 and 2002 Table Properties dialog – see How to sidestep the problems of the Word
2000 (and higher) Table Properties dialog for details.

Even distribution
An extremely useful option introduced in Word 97 is the “Distribute columns evenly” command. If
you select two or more adjacent columns, right-click, and choose this option, the total width of the
combined columns will be divided equally among them so that they are the same width.

Adding rows or columns


As you have seen, adding new rows at the end of a table is easy and automatic. But what if you
want to insert rows in the middle? Or what if you have gotten too far along in your table to start
from scratch when you discover you need an additional column? No problem!

When you select a row or a column, one of the items on the right-click shortcut menu will be Insert
Rows or Insert Columns. Or you can use the context-sensitive Table button (see Figure 4). When
you use one of these commands you will insert a row above the selected one or a column to the
left of the selected one.

If you select more than one row or column, Word will insert the number of rows or columns
selected. This is an easy way to insert a lot of rows at once, even at the bottom of the table. Select
the last (still empty) row and choose Insert Rows; select that row and the new row and press F4
(Repeat) to insert two more rows; select the four rows and press F4 to insert four new rows; and so
on.

In Word 2000 and higher, you can choose whether to insert new rows above or below the selected
row or new columns to the left or right of the selected column. This can be important when you
want to add a row that duplicates the formatting of the row above it rather than that of the one
below (a row above a totals row, for example). On the Table menu, choose Insert, then Columns to
the Left, Columns to the Right, Rows Above, or Rows Below.

Word 97 and earlier don’t have these commands, but there are workarounds. To add a new row
below an existing one, position the insertion point at the end of the text in the last cell in the row.
Press the Right Arrow key (not Tab). This will position the insertion point just outside the cell, to the
left of the end-of-row marker (which you can see if you have nonprinting characters displayed).
Press Enter, and a new row will be inserted below the existing one. To insert a new column to the
right of the farthest right one, select the end-of-row markers the same way you would select a
column and choose Insert Columns.

Deleting rows, columns and tables

13
To delete a row or column, select it, right-click, and choose “Delete rows” or “Delete columns.”
(You can also use Cut.) To delete an entire table, select it and use either Cut or Table | Delete
Table; in Word 2000 and higher, you can also delete a selected table by pressing Backspace.

Repeating headings
If your table is longer than one page (or continues onto a second page, regardless of length), you
can make your headings automatically repeat on the following page(s). In Word 97 and earlier,
select the row(s) you want to repeat and check “Headings” on the Table menu. You can repeat
more than one row, but they must be the top rows of the table (you can’t skip any rows).

In Word 2000 and higher, select the desired heading rows and check “Heading rows repeat” on
the Table menu. (There is also a check box on the “Row” tab of the Table Properties dialog for
“Repeat as header at the top of each page.”)

Positioning the table


If your table is less than the full margin width, you may want to indent or center it. The Row tab of
the Table | Cell Height and Width dialog (Word 97 and earlier) and the Table tab of the Table
Properties dialog (Word 2000 and higher) allow you to specify Left, Center, or Right alignment for
the entire table (you can also select the entire table and use the Left, Center, or Right alignment
buttons on the Formatting toolbar). Both these dialog tabs also allow you to set a specific left
indent if you choose.

Having used the Cell Height and Width dialog to set these properties for one table, you can apply
the same properties to any other tables by clicking in them and pressing F4. If using Word 2000 or
higher, see: How to sidestep the problems of the Word 2000 (and higher) Table Properties
dialog.

Controlling text flow


You may have already learned to control page breaks in Word by using a combination of the
properties on the Line and Page Breaks tab of Format | Paragraph: “Widow/Orphan control,”
“Keep lines together,” “Keep with next,” and “Page break before.” These work a little differently in
tables.

“Widow/Orphan control” and “Keep lines together”


These paragraph properties have no effect in a table. There is a check box on the Row tab of
Table | Cell Height and Width or Table Properties that allows you to specify whether you want to
allow a soft page break within a given row (“Allow row to break across pages”). But if you do allow
the row to break, it can break anywhere, even if the result is to leave one line of text stranded on a
page. If you have more than one paragraph in a cell and would like the row to be able to break
between but not within the paragraphs, you’re just out of luck.

“Keep with next”


This command does work, but only between rows. At a minimum, it should be applied to the
header row(s), but it is also very useful for keeping a table together on one page. To do that, apply
it to the text in every row but the last.

If you want to ensure that the first few rows of the table always stay together (so that you don't, for
instance, ever end up with only the table header row at the foot of a page) apply “Keep with next”
to the first two or three rows.

14
“Page break before”
This one is quite useful. Sometimes you will want to break a table at a certain point. But if you
insert a hard page break (Ctrl+Enter), the result is to split the table, and heading rows will not
repeat. But you can apply the “Page break before” property and you will get the desired page
break and repeating headings. (You can also apply “Keep with next” to the preceding rows to
achieve the same effect.)

Performance issues
See: Maximising the performance of Word tables.

Advanced techniques
All of the above is more than enough to get you started creating basic tables, but Word allows you
to do a lot of other fancy things in tables.

Merging cells
All versions of Word allow you to merge and split cells horizontally. Word 97 and above also allow
you to merge and split cells vertically (and also to adjust cell widths independently of the column
width). To merge cells, select the cells to be merged (combined), right-click, and choose Merge
Cells.

Although in Word 97 and above you can merge cells both horizontally and vertically, there are
limitations. You cannot create an L-shaped cell. If two cells are merged vertically, then the
combined cells cannot be merged horizontally with a single cell but only with the two adjacent
cells. But even in earlier versions, where you cannot merge cells vertically, you can often create
the appearance of merged cells by applying borders selectively.

In Word 95 and earlier, if you merged two columns, you in effect merged the two cells in each row
of the two columns; in Word 97 and later, unfortunately, you merge the two entire columns into one
big cell, which isn’t very helpful! You can get around this, however, by using the Eraser tool on the
Tables and Borders toolbar; if you use it to erase the border between two columns, the rows
remain intact.

Figure 7: The Eraser tool

Merging should be approached cautiously and conservatively. Don’t merge cells horizontally until
you are sure the column widths are final. The reason for this is that selecting and sizing columns is
complicated by merged cells. And don’t merge cells at all if you don’t have to. If you can achieve
the same effect by omitting borders, do that instead. Merging cells makes a table more complex
and susceptible to corruption, which is reason enough to avoid it except when absolutely
necessary.

Vertical alignment
By default Word places text at the top of a table cell (subject to any “Spacing Before” you have
applied to the paragraph). But sometimes, as in a price list, for example, you may want to align text
at the bottom of the cells. In Word 97, you can choose Top, Center, or Bottom alignment for all the
text in a given cell. This command is on the right-click shortcut menu when the insertion point is in

15
a given cell. (By default it does not appear when you have an entire row selected, but you can add
it through Customize.) It also appears on the Tables and Borders toolbar. (Although this feature is
very useful, if you must share documents with users of versions earlier than Word 97, keep in mind
that the alignment will not be retained because it is not supported in previous versions. In those
versions you will need to use Spacing Before or line breaks to position text other than at the top of
a cell.)

Word 2000 and higher have substituted a table alignment palette that displays nine combinations
of vertical and horizontal alignment. If you have defined the horizontal alignment as part of your
style, you will prefer the Word 97–style vertical alignment menu. You can restore it following the
directions in How to fix the Word 2000+ Cell Alignment buttons.

Text direction
In Word 97 and above, you can rotate text in a table cell 90 degrees right or left. The text rotation
is displayed only in Page/Print Layout view and applies to all the text in the cell. This is useful
when you have long headings for narrow columns. The Text Direction command is on the right-
click shortcut menu when the insertion point is in a cell, as well as on the Format menu and the
Tables and Borders toolbar. (Again, keep in mind that this feature is not supported in earlier
versions.) When text is rotated, the “horizontal” and “vertical” alignment buttons are rotated
accordingly, which can be a little disconcerting.

Figure 8: The Cell Alignment buttons when the selection is in a normal


table cell (left), and in a cell in which the text has been rotated (right)

Cell margins
Space around the text in cells is achieved in several different ways.

In Word 97 and earlier, the left and right cell margins are determined by the “Space between
columns” measurement on the Column tab of Table | Cell Height and Width.

Word 2000 and higher, instead of the “Space between columns” setting, have “Cell margins”
settings that can be established as a default for the entire table or specified for individual cells. Set
default cell margins for the entire table in the “Table Options” dialog accessed via the Options…
button of the Table tab of Table Properties. Set margins for a specific cell (or selected cells) in the
Cell Options dialog accessed via the Options… button on the Cell tab. You can also still use
paragraph indents in cells, but this should not be necessary except when you want one paragraph
indented more than the rest in a single cell.

The default setting for the “Space between columns” is 0.15", or .38cm, resulting in 0.08" left and
right margins being displayed Under Table | Properties | Options in Word 2000 and above, if you
use inches (although the true left and right margins are actually 0.075"); or 0.19cm being displayed
if you use centimetres. It can be reduced to 0" (no space between columns) or increased as
desired.

This setting applies to all cells in the table, but you can increase “cell padding” using paragraph
indents. You can also reduce the effective cell margin in a given cell by setting negative paragraph
indents; this technique should be used sparingly, however, since it can have very odd results when
the column width is changed.

In Word 97, top and bottom margins (if any) must be created by applying Spacing Before and/or

16
After to the paragraphs in the cell.

In Word 2000 and higher, you can set Top and Bottom cell margins by selecting Table |
Properties | Options – but note that any such margins will disappear if a Word 97 user opens
your document.

Word 2000 and above also support something quite different, rather confusingly called “Spacing
between cells”, also accessible via Table | Properties | Options. This setting seems to be there
for the sake of HTML compatibility (it is equivalent to HTML's “cellspacing”). It creates an ugly
effect whereby, instead of adding cell margins, as the cell margins settings do, it adds white space
in the middle of the cell borders, splitting each border in two:

This table has cellspacing applied cellspacing is not really appropriate for use in Word.
Figure 9

Graphics in tables
In Word 97 and earlier versions, floating graphics and tables are not compatible. You can insert
pictures as “inline” objects (that is, objects in the text layer) in a table, but you can’t wrap text
around them. Sometimes you can fudge by splitting a cell and putting a graphic in part of it and text
in the other (as has been done with many of the graphics in this article); but this is not always
satisfactory. And you can’t put Word’s drawing objects (AutoShapes, text boxes) in Word 97 tables
at all unless you first convert them to inline objects (using Copy, then Paste Special as Picture,
with the “Float over text” check box cleared).

In Word 2000 and above, you can insert floating images in table cells. “Floating images” are
those with a wrapping style other than “In line with text” (on the Layout tab of the Format Picture
dialog). Images that have “Behind text” or “In front of text” wrapping can float freely over the table
without being confined within a table cell. An image with “Square,” “Tight,” “Through” or “Top &
bottom” wrapping will be confined to a cell. If the image is resized to a larger width, the table cell
will adjust to accommodate it.

Having said that, though (and as discussed in the article The draw layer: a metaphysical space),
it is best to use floating graphics only when they are really needed; and in long documents it is best
to avoid them altogether, other than in Headers, Footers, and on the cover page. And if you do
need to use floating graphics in a table, it is usually best to ensure that their anchors are placed
outside the table – see, for example, the article: Floating objects in Word 2000 table cells are
vertically aligned wrongly.

Nested tables
In Word 2000 and higher versions, you can embed (“nest”) a table within a cell of a larger table
(for an example, imagine the thumbnails of the previous and following months that might appear in
the unused day spaces of a monthly calendar). Nested tables make a document much more
complex, can slow Word documents down dramatically; and the behavior of the tab key is
changed.

The existence of nested tables also complicates working with ordinary tables: because now you
can insert tables within one another, you may see new pasting behavior when you paste tables.
There are specific rules for this behavior, but in general they are pretty logical, though usually
irritating in practice. To summarize, you can paste equal numbers of cells as cells, but if you try to
paste several cells into a single cell, they will be pasted as a nested table. To prevent this from
happening, drag and drop your cells instead of pasting them; or select Edit | Paste Special as
Formatted Text (which is the only workaround when pasting from Excel into a Word table).

17
Well-designed web pages would be impossible to create without nested tables, because the only
way to set the width of a web “page” is to put all your text (and any tables within the text) inside a
fixed width table cell; but nested tables are rarely either appropriate or useful in Word: avoid them
when you can.

If you do use nested tables, you will get unpredictable results if the documents are ever opened in
Word 97 or earlier.

“Text-wrapped” tables and frames


You can also turn “text wrapping” on, for Word 2000+ tables, by selecting Table | Properties, and
setting the “Text Wrapping” to “Around”. This means you can wrap text around tables, or put two
independent tables side by side. Despite appearances, such tables are not “floating” (that is, they
are not in the drawing layer, and they can be seen in Normal View). In fact, they are in a frame,
(although in the case of Word 2002, a frame with a difference; as you see will see shortly); but the
frame borders are hidden when the document is open in Word 2000 and higher. If you open the
same document in Word 97, the frame borders become visible.

So in case you hadn't already realised this, you can wrap text around Word 97 tables, or put two
independent Word 97 tables side by side, by putting the tables into frames.

It is all too easy to switch a table's “text-wrapping” on inadvertently. When you are working in a
table in Word 2000 and above, you may see a four-headed arrow in a box at the top left corner of
the table (like the one on the left). This “table handle” appears only in Print Layout view. If you
click on it, you can drag the table anywhere on the page. It then becomes “text-wrapped”. Even if
you drag it just ever so slightly, the table becomes text-wrapped. Needless to say, you must be
careful not to drag the table accidentally when selecting text in the first cell.

The lack of visibility of the frame borders in text-wrapped tables, combined with the ease with
which you can accidentally turn text-wrapping on, makes for a maintenance nightmare, as it is
often difficult to tell whether a table has wrapping switched on or not.

In Word 2000, text-wrapped tables cannot span multiple pages – but can overlap both the footer
area and the non-printing area at the bottom of a page – so you can imagine the problems this
causes people!

In Word 2002, text-wrapped tables can span multiple pages – and they do so by default, which
makes it even more difficult than in Word 2000 to tell whether a given table is text-wrapped or not!
The wrapping of text around Word 2002 tables that span multiple pages behaves very strangely
indeed; for example, if you insert a table in the middle of text and wrap text around it, as soon as
the table breaks to the next page, all the wrapped text goes with it. Although some of the table
stays on the first page, the text breaks off above it, giving an ugly effect.

Fortunately, you can switch off the ability to span multiple pages by selecting Tools | Options |
Compatibility, and selecting “Don't break wrapped tables across pages.” If you do that in your
templates, your new documents will pick up that setting. Or clearing the “Move with text” box in the
“Table Positioning” dialog under Table Properties also switches off the ability of a text-wrapped
table to span multiple pages.

If you send a Word 2002 document containing a text-wrapped table that spans more than one
page to a Word 2000 or Word 97 user, it will all be on one page when they open it; it may well
overlap the Header and Footer; and some of the table may be off the page completely (and
therefore invisible).

Text-wrapped tables, like frames and floating objects, also add a memory overhead, slow your
documents down, and increase the risk of document corruption. Using text-wrapping when it's

18
needed is one thing, but it should never be used if not needed, and therefore the ease with which
wrapping can be accidentally applied is very unfortunate.

So it is usually much better to do things the old-fashioned way, even in Word 2000 and above, and
insert a “proper” frame (just select the table and click the Insert Frame button), rather than using
the invisible frame that gets inserted when you turn text-wrapping on. The functionality is identical,
but a visible frame makes it far easier to see what's going on than an invisible one does; and
makes for far more maintainable documents. See also: How can I add the Insert Frame
command to the Insert menu?

Tables and HTML


Most of the changes in table formatting that were introduced in Word 2000 are intended to make
Word more compatible with web documents (so that, for instance, you can paste web documents
into Word without losing any formatting); and also – a much more minority taste – to make Word
more suitable for creating Web pages. Nested tables, for example, are widely used in HTML, and
they persist when documents are round-tripped (saved back and forth) between document to
HTML file format.

Drawing tables
The Tables and Borders toolbar has a Pencil tool that allows you to draw a table (also accessible
via Table | Draw Table). The premise is that you can easily create custom-sized cells without the
bother of merging or splitting. The reality is that you can easily get yourself into a whole pile of
trouble, especially when you start trying to size the cells or use the Eraser; and also, if you use this
tool you will inevitably make your tables unnecessarily complex without realizing it. It actually takes
a great deal of skill not to make a mess of your tables, if you use the pencil tool. I have had to sort
out the mess made by many users who have used it, and my advice about drawing tables
therefore is: Don’t.

Wide tables
Occasionally you will need to create a table that is just too wide to fit between the margins of a
normal portrait page. In this case you have several options:
1. The most straightforward approach is to insert a landscape page or pages in order to make
the table wider. Although this method has its drawbacks, especially if you need to preserve a
portrait header and/or footer (see How can I create a landscape section and still have a
portrait page number?), it’s the conventional way of tackling the problem.
2. It may be possible to rotate the table layout, swapping headings and stubs, so that it is
longer than it is wide, but this doesn’t always help if the cell text itself is wide or if this distorts
the table logic.
3. It is conceivably possible to effectively rotate the table itself, swapping headings and stubs
and then rotating the text 90 degrees, but this is a gargantuan mental effort, and rotating text
adds complexity to the document.
4. If the table will not need editing, you could create it as a separate landscape document and
then use Copy and Paste Special: As Picture for one page at a time. The inserted picture
can then be rotated.
Needless to say, methods 2, 3, and 4 are offered in a purely academic spirit; in most cases the first
one is what you will use.
Users, especially those more at home in Excel, sometimes ask whether it is possible to split a table
across two portrait pages. There is no built-in way to do this in Word. You can manually set up a
broadside table to spread across two facing pages, but you have to construct it by hand, and if row
heights are likely to vary, you’ll need to make them all Exact so that they will match from one page

19
to the next. Again, this requires a lot of mental effort and manual tweaking, so generally it is better
to rethink the table and either divide it into two or more tables or run it broadside on a landscape
page or pages.

Narrow tables
Sometimes you will have a long, narrow table that would be much more efficiently displayed in two
or more columns. There is no reason not to do this. It is generally easier if you set up the column
formatting before inserting the table so that the inserted table will be the width of the column rather
than the full margin width.
You can create a multi-column section manually, by inserting section breaks and then applying the
desired column formatting to each section, but you can also get Word to do the work for you. At the
end of the text preceding the multi-column section, press Enter twice to create two empty
paragraphs. Select the first one and use Format | Columns (or the Columns button on the
Formatting toolbar) to select two or more columns. Word will insert the necessary Continuous
section breaks above and below this paragraph, where you can now insert your table.
Because you have a Continuous section break at the end of the multi-column section, Word will
automatically “balance” the columns (unless you tell it not to with the appropriate setting in Tools |
Options | Compatibility). This can be distracting when you are creating the table because every
time you add a row, the table shifts from one column to another. If you work in Normal view, this
will not be a problem. (For more on working with columns, see The strait and narrow: using
columns.)
When you have a table divided across multiple columns, you will find that heading rows repeat at
the top of each column. But you may wonder how to force table rows into the next column. If you
insert a column break (Ctrl+Shift+Enter or Insert | Break: Column), the headings will not repeat,
and there is no “Column break before” property for paragraphs. In this situation you will have to
apply “Keep with next” to the rows you want to move to the next column.
If your table is very well defined and there is no possibility that you will need to add or delete rows,
and if all the rows are of uniform height, you can create the appearance of a multi-column table
without actually using snaking columns. Just create a table with twice as many columns as you
need, plus one. Use the centermost column (with borders removed if you’re using borders on the
rest of the table) as the “gutter” between your “columns” and fill the two sides of the table just as if
the “table” on the right were a continuation of the one on the left.

Changing your mind


Suppose you start making a simple table using tabs and are pretty far along when you realize you
really need to use a Word table. You could insert a table and drag the bits of text into the cells, but
Word provides an easier way: Convert Text to Table. If you already have a table set up with
tabbed columns, you can select it and choose this command from the Table menu. In the resulting
dialog, make sure that Word is planning to separate the text at the tabs and that the number of
rows and columns it expects to make is correct. When you press OK, your tabbed table will be
converted to a Word table; Word even does a pretty good job of setting column widths. You’ll still
have some formatting to do (beginning with removing the automatic grid border), but it’s sure
quicker than starting from scratch!

20
21
Why don't my table borders print?

Article contributed by Suzanne Barnhill

If most of the borders are okay and just the bottom border (or right border on a landscape page)
is not printing, the problem is probably that they are in your printer’s unprintable area.
If the borders don’t print at all, in rare cases the problem may also be due to the printer driver
(especially if you’re using a text printer that can’t print graphics). The most likely explanation,
however, is that you have confused borders and gridlines.
In grade school you probably learned that the equator is “an imaginary line” around the center of
the earth. Gridlines, like the equator, are “imaginary lines,” a visual representation of the table cell
boundaries. They do not print.
Display of table gridlines is toggled on and off by Table | Show/Hide Gridlines (in Word 2007,
Table Tools | Layout | Table | View Gridlines). Gridlines are displayed in both Normal (Draft)
and Print Layout views but not in Print Preview because they do not print. In Print Layout view,
even if you have table gridlines hidden, you will see a dotted line representing cell boundaries if
you have “Text boundaries” checked in Tools | Options | View (in Word 2007, Office Button |
Word Options | Advanced: Show document content: “Show text boundaries”).
If you want table borders that print, you will need to apply borders to the table or selected cells or
sides of cells. For more on this, see Run for the border.
Users often don’t realize that Word uses tables to format labels. If you choose “New Document”
on the Labels tab of the Tools | Envelopes and Labels dialog (Mailings | Create | Labels in
Word 2007), the page you get will be a sheet of labels set up as a table. If you don’t have table
gridlines displayed, it will appear to be an entirely blank page. With gridlines displayed, you will
see the label structure. If you also display nonprinting characters, you can see the end-of-cell
markers ¤ (even without the gridlines), which give you another clue.
If you want to be able to toggle table gridlines on and off easily, you may want to add a Gridlines

22
button to a toolbar or the QAT, as follows:
Word 2003 and earlier: Go to Tools | Customize. On the Commands tab, select
Table under “Categories” and Gridlines under “Commands.” Drag the button to a
toolbar (next to Insert Table on the Standard toolbar is a logical place). Since the
button is a toggle, it has (as on the Table menu) two button faces and two
ScreenTips:

Word 2007: Right-click on the View Gridlines button on the Ribbon and choose “Add to Quick
Access Toolbar.” This button will also be a toggle with the same button face as above.

23
Run for the border: using borders in Word

Article contributed by Suzanne Barnhill

Applies to Word 2004 and earlier.

You can create a wide variety of special effects in Word using paragraph and table borders. Use of
borders, however, is often misunderstood. This article will attempt to clear up some
misunderstandings and provide useful tips for using borders effectively.

Borders, boundaries, gridlines


One of the most common problems in dealing with (and talking about) tables in Word is failure to
distinguish between borders and gridlines.

When you insert a table in most versions of Word, it is by default given a ½ pt single rule border
around all cells. Since there are many uses in Word for borderless tables, the first thing many
users want to do is remove the borders. And, provided this is the first thing you do, it’s relatively
simple, in most versions of Word: if you press Ctrl+Alt+U (TableUpdateAutoFormat) immediately
after inserting the table, the borders will be removed. Unfortunately, in some language versions of
Word 97, including UK English, pressing Ctrl+Alt+U inserts a ú symbol instead of removing the
borders, so you have to assign TableUpdateAutoFormat to a different shortcut instead – you can't
assign Ctrl+Alt+U to TableUpdateAutoFormat yourself, because it's already assigned to it; it just
doesn't work in some language versions of Word (this appears to be a bug).

Word also displays table gridlines by default (Table | Show/Hide Gridlines), so it may not be
immediately obvious that a table is borderless. As explained in Why don’t my table borders
print?, gridlines are merely a visual representation of cell boundaries. They do not print. To make
“gridlines” that will print, you have to apply a border.

Access to borders
There are (at least) three ways to apply or remove borders in Word: the Format | Borders and
Shading dialog, the Tables and Borders toolbar, and the Borders button on the Formatting toolbar.
They offer varying levels of customization.

24
Level 1: Borders and Shading dialog
The Format | Borders and Shading dialog gives you the most control over borders and also gives
you access to Page Borders (Word 97 and above) and shading. Using the Setting buttons, you can
choose from among several preset borders. Borders can be applied to tables, table cells, text
paragraphs, and selected text, and the preset borders offered vary according to the context. For
text paragraphs, for example, Word offers the “Shadow” and “3-D” options, which should
automatically apply a combination of borders to create a shadowed or 3-D effect. Actually,
although “Shadow” will work with any border or line weight (and the only way to get a deeper
shadow is to choose a heavier line), “3-D” doesn’t work at all unless you choose one of the line
styles that combine lighter and heavier lines. It merely reverses the inside and outside lines to
create the 3-D effect.

If you are working in a table, the presets include the “All” and “Grid” options. “All” applies the
same border to all cell boundaries, both outside and inside. (This is the default format when you
insert a table.) “Grid” appears to do the same thing (although it actually changes the inner border
to ¾ pt!) – until you choose a different line weight or style; Word then applies that to just the
outside boundaries, giving you a heavier line around the entire table and, by default, a ¾ pt rule for
the inside boundaries.

Using this setting, the only way to get heavier Inside lines – or lighter ones than ¾ pt – is to format
them manually in the Preview. After selecting “Grid” and applying your thick outer border; but
without closing the dialog, click on one of the inner lines in the preview pane before you change
the width setting (otherwise you will just end up changing the weight of the outer border again!).
Now change the Width setting to whatever weight you want the inner border lines to have; and
click both the horizontal and vertical inner lines in the Preview. Then click OK.

A good general rule to remember when changing the weights of lines in the Preview pane is that
you must always select the line you want to adjust before you change the Width setting; which is
downright unintuitive, but once you know the rule, it's simple enough to apply.

25
Another option is “Custom,” which allows you to select different line weights and styles for various
sides of a cell or paragraph. Actually, you don’t have to choose this option; it will be chosen for you
if you change a given border from the set Box, All, Grid, Shadow, or 3-D settings. It is not
immediately obvious how to do this, though. You must first select the line weight, style, and color,
then click on the appropriate line (or corresponding button) on the Preview at the right side of the
dialog (if you click these lines or buttons before selecting a line, you will either apply the default
style or, if it is already applied, remove it). If you are applying a border to text paragraphs, you will
not have the Inside option unless you have more than one paragraph of text selected. This is more
difficult to explain than to figure out; with a little experimentation, you will see how the preview
works.

If you are formatting entire text paragraphs, the Options… button will be enabled. The Options tab
allows you to set (from 1 to 31 points) how far the border should be from text. The defaults are 1
point top and bottom and 4 points left and right. The distance options are available only for the
sides of the paragraph where you have a border. If you want a top border, for example, to extend
beyond text right and left, changing the Left and Right options will have no effect; the border will be
exactly the same width as your paragraph. You can get around this by applying a white
(nonprinting) border on the sides and then setting the distance as needed.

In tables the Options tab is unavailable. To increase the distance from text, you must use
paragraph indents (left and right) or Spacing Before/After (top and bottom) in Word 97 and earlier
or adjust the cell padding in Word 2000 and above. In text paragraphs, Spacing Before/After is
added above or below the border; if you want additional space before and/or after a table, you will
have to add Spacing After to the paragraph above and/or Spacing Before to the paragraph below.

If you are trying to border selected text (less than an entire paragraph), the dialog appears to allow
you to choose which sides of the text to border, but in fact the only available options are those that
create a box (Box, Shadow, and 3-D), and you cannot adjust the distance from text. If you want to
put a border on one or more (but not all) sides of selected text, investigate the EQ field in Word’s
Help; the \x switch for this field, together with switches that indicate top, bottom, left, and right,

26
allows you to do this.

Level 2: Tables and Borders toolbar

By default there is a button on the Standard toolbar (next to Insert Table) to toggle display of the
Tables and Borders toolbar. Although this toolbar is by default floating, you can, if desired, dock it
at the top or bottom of your screen to get it out of the way. (Docking it at the side is not
recommended; if you do that, the dropdown list boxes become buttons that bring up the Borders
and Shading dialog.)

With this toolbar you can accomplish many of the same things you can do in the Borders and
Shading dialog, although for most purposes, the Borders and Shading dialog works better.

You can choose a line style, weight, and color and, using the Borders palette, apply borders to an
entire table (or paragraph) or selected cells. (You don’t have access to the Options tab, but this is
unavailable in tables, anyway.) The Borders palette has ten buttons you can use to apply Inside,
Outside, Top, Bottom, Left, or Right borders or a grid (All) or to remove borders entirely (No
Border). You can also remove borders selectively by clicking “on” buttons to turn them off. The
border applied by the buttons on the Borders palette defaults to the most recently selected style,
weight, and color, which is displayed on the toolbar.

If you will be applying many borders of the same weight to selected sides of selected table cells,
you may find it more convenient to display the Borders palette alone. Click the down arrow on the
Borders button and release the mouse button. As you pass the mouse over the top of the palette,
you will see a tiny title bar become active, and a ScreenTip says, “Drag to make this menu float.”
Click on the title bar and drag the palette off the toolbar. You can then close the Tables and
Borders toolbar, leaving the Borders palette floating. This little toolbar doesn’t really get in the way,
but you can dock it on any side of your screen if desired.

Incidentally, the Borders palette in Word 2000 and above, as shown in these screen captures,
contains three buttons that are not present on the Word 97 one, all three being almost completely
useless! The two “diagonal” buttons create diagonal lines that intersect your text like this:

They do not actually split your cell diagonally; they just create the appearance of doing so. If you
want to further this deception, you will need to format text accordingly:

The “Horizontal line” button inserts a web-based horizontal line (i.e. an <hr> tag) like this:

27
... which is similar to applying a paragraph border but far less flexible (for instance, you have no
control over its color, its thickness, or its distance from the text). There is never likely to be an
occasion when you would want to use any of the new buttons!

One thing the toolbar is good for is applying fills; in Word 97 and above, when you apply a fill using
the Borders and Shading dialog, it often changes your borders in unexpected ways. Unfortunately,
there are also some disadvantages to using the Tables and Borders toolbar.

Level 3: Borders button on the Formatting toolbar


The Borders button on the Formatting toolbar opens the same palette as the one on the Tables
and Borders toolbar. You don’t get the option of selecting line style, weight, and color (it merely
applies the currently selected default), but you can “tear off” this palette to make a floating toolbar
the same way you can the one on the Tables and Borders toolbar. For quick formatting, and
especially for removing borders, this is definitely the quickest method.

Some “gotchas”

Conversely, if consecutive paragraphs have the same formatting and have the same
border style applied, they will all be in the same box. You can apply an Inside border to separate
the paragraphs, but if you want them to be actually in separate boxes, there are two ways to
accomplish this:

1. Insert an unbordered paragraph between them. Format the line spacing of the paragraph to be
Exactly the distance you want between the boxes. This assumes that the two paragraphs do not
have any Spacing Before or After

2. If your paragraphs have Spacing Before or After and you want to preserve this distance
between the boxes, you can use a more devious method: take advantage of the first “gotcha” and
make the paragraphs different. Give one of them an infinitesimal indent. If you press Alt while
dragging the left or right margin marker on the ruler, you can move it as little as 0.01".

You may find that you sometimes get borders when you don’t want them. If you have not
cleared the check box for automatic borders on the AutoFormat As You Type tab of Tools |
AutoCorrect, these may appear as unexpectedly (and as welcome) as the Spanish Inquisition.
For more on this, see There is a line in my document that I can't delete.

If you are coming to Word from WordPerfect, you may be accustomed to seeing a distinct
difference between a bottom border on one cell and a top border on the one below. Perhaps
you've even combined these to get a double or heavier border. But you may also have found that
this arrangement often made it very difficult to align intersecting borders properly. Word works
differently: a bottom border on one cell is in exactly the same location as a top border on the cell
below. This is normally a good thing, but every now and then Word, in its infinite wisdom, will
decide that the border you applied as a bottom border is actually at least in part a top border on the
cell below, making it impossible to remove it by turning off the Bottom Border button on the

28
Borders palette. At such times you must just shrug and move on to the cell below and remove the
top border.
Tables continued from one page to another often lose the bottom border of the last row;
sometimes you can restore it by explicitly applying a bottom border to that row (not just borders
between rows). Word has a way of perversely interpreting a border between rows as being the top
of one row or the bottom of another, but not both.

Some disadvantages of using the Tables and Borders toolbar


1. If you display the Tables and Borders toolbar by clicking the button on the Standard toolbar,
the “Draw Table” (pencil) button is switched on automatically, ready for you to start drawing.
Worse still, if you then turn the “Draw Table” off, by pressing Escape, it reappears again, like a
bad penny, as soon as you change the “Line Style” “Line Weight”, “Border Color” or almost any
other setting. For reasons discussed below under Drawing Tables, the “Draw Table” feature is
usually best avoided, so the toolbar's addiction to turning the feature on is very frustrating to
experienced users and a major pitfall for inexperienced ones.

2. As mentioned above in “Some ‘gotchas,’” the Borders palette on the Tables and Borders
toolbar (as well as the one on the Formatting toolbar) does not “pick up” the borders that have
already been applied to cells. (The dialog doesn't always either, but it is far better at this than the
toolbar is). As a result, the toolbar is not suitable for tweaking the border formatting of cells that
have already had borders applied.

3. It is almost impossible to apply grids with different outer and inner borders using the Tables
and Borders toolbar, whereas it is simplicity itself using the Borders and Shading dialog. For
instance, if you select a range of cells and then select “Grid” in the dialog, you can apply different
outer and inner borders in a one-step process; whereas the Toolbar grid button won't let you do
that (it applies the thick border throughout).

4. Although the toolbar buttons can be used to apply borders to paragraphs of plain text, results
in table cells are unpredictable because there is no way to specify whether the border is to be
applied to the table cell, a paragraph in the cell, or selected text.

5. See also: How to fix the Word 2000+ Cell Alignment buttons.

Drawing tables
If you draw a table using the pencil tool on the Tables and Borders toolbar, the cells are given the
default ½ pt black rule border unless you have selected a different line style, weight, and/or color
on the toolbar dropdown before drawing the table. You can change the borders using the tools on
the toolbar. You can also remove all or some of the borders by selecting cells and clicking the
appropriate buttons on the Borders palette. It may be tempting to use the Eraser tool to erase
borders, but this often doesn’t work; what frequently happens is that you instead erase the cell
boundary, thereby merging two adjacent cells, which may not be at all what you intended. The
Eraser tool does have one real use though. It provides by far the quickest way of merging two
columns. But even for that it is flawed – you can only merge one page's worth at a time!

I personally don’t recommend drawing tables. I have yet to find a table that could not be effectively
created using Insert Table and then adjusting cell widths and merging or splitting as necessary.
And I have seen (and corrected) some horrible messes made by inexpert users using Draw Table
(actually, even for expert users, it is very difficult to avoid making a mess of your tables if you use
this tool).

If you do use the table drawing tools, be sure to display cell gridlines and/or text boundaries so you
will know if you have inadvertently erased a cell boundary when you meant to erase a border;
better yet, don’t use the eraser for anything except erasing cell boundaries.

29
30
31
The strait and narrow: using columns

Article contributed by Suzanne Barnhill and Dave Rado

When you open a new blank document in Word, you begin typing at the left side of the
screen/page and continue typing to the right margin, where Word wraps your text back to the left
so you can start again. All your lines of text are full width. But sometimes you need to divide your
text into two or more columns.

Types of columns (tables, snaking columns, or ??)


Word gives you several different ways of lining up columns of text. Which one you use depends
on what you want the text to do.

Tabs
If you want to enter text in one column, then text in another column on the same line, then more
text in the first column (but on the next line), and so on, and if each of the entries will fit on one
line, you may be able to align the columns using tabs. What you're doing here is creating a
“tabbed table”:
Just be sure you set a specific tab stop for each column location; don't use Word's built-in tabs.

Tables
If you want to be able to enter some text in one column, then text in another column aligned with
it, then text in the first column again, then the second (and possibly a third, fourth, or more), and if
the text in each column must be able to wrap to the next line, then what you want is a table. A
table allows you to align text vertically as well as horizontally. Whenever you need to “synch” the
columns, you begin a new row.
Table columns are especially good for things like opera scores, where you need the text in the
original score and the translation to line up with each other vertically.

Text box columns


It is possible to get text to flow from one Text Box to another. To do this, click on the first Text
Box, then click on the Link button on the Text Box toolbar that will now be visible, and click on the

32
second textbox.
The idea of Text Box columns is that, unlike snaking columns (which are covered in detail below),
they can be used to cater for articles which start on page 1 of a publication and continue in the
middle of page 14. An example is to be found in the (appallingly formatted!) Newsletter Wizard
that is supplied with some versions of Microsoft Office (Word 2007 has no wizards, but there are
plenty of equally appalling templates in the Template Gallery at Microsoft Office Online).
However, Text Box columns don't work well and are best avoided. If you need the ability to flow
text between non-consecutive pages, you will save yourself a lot of heartache by using a DTP
package such as MS Publisher or Adobe PageMaker. For most purposes, however, snaking
columns work admirably.

Snaking columns
If you want the text to fill the first column and then snake into the next and fill it, continuing from
Column A to Column B, then Column A on the next page, then you want newspaper-style
columns, the subject of this article. (Note that this type of columns is not appropriate for text to be
aligned vertically across the page; for that you need to use a table).
If you can make any sense of the above passage,
you should have no trouble learning to work with columns!

Parallel columns
If you are coming to Word from WordPerfect, you may be used to having another option: parallel
columns. Word doesn't offer this option, but you can achieve the same effect using a one-row
table with the required number of columns. Be aware, though, that Word can be uncomfortable
with very long single-row tables, which may lead to document corruption. Usually you will want to
start a new row occasionally, anyway, to line up text in the two (or more) columns.

How many columns?


The most common reason for using newspaper-style columns is to create (as the name suggests)
something like a newspaper. Dividing the page width into narrower lines allows you to use smaller
type without creating an unreadable line length. (A general rule of thumb is to have no more than
1½ alphabets, or 40–60 characters, in a line.) For some documents, such as newsletters, the
number of columns can vary, and columns may be of unequal widths. For other documents, such
as a three- or four-panel brochure, it makes sense to have one column of text for each panel
(though sometimes a heading or other design element or even an entire column will spread over
two or more panels). However many columns you decide to have, and whether they are of equal
or unequal widths, you can easily create them in Word.

Getting started
Sometimes you will want just one portion of your document to have multiple columns. We'll
discuss later how to accomplish that. For now, however, let's assume that your entire document
will be multicolumn. For illustration purposes, let's say that it is a four-panel brochure on legal-
sized paper in landscape orientation.

Planning your columns


Since the document will be folded, you will want to allow enough space between the columns to
leave a reasonable margin on each panel. This margin should be the same as the outside
margin, meaning that the space between columns will need to be double the outside margin. By
default, Word puts half an inch between columns, so you could make your outside margins a
quarter of an inch, but that might be pushing the limits of your printer or a photocopier, so let's
say you'll set 0.3" left and right margins and plan to have 0.6" between columns.

33
Word 2003 and earlier: After setting your document margins in File | Page Setup, click
on the Columns button on the Standard toolbar, drag to select four columns, and
release. Your document will now be divided into four columns. You can also use Format |
Columns to access the Columns dialog.
Word 2007: After setting your document margins through Page Layout | Page Setup |
Margins or in the Page Setup dialog (accessed via the dialog launcher arrow in the
bottom right corner of the Page Setup group), click Columns in the Page Setup group
and choose More Columns… This opens the Columns dialog (see figure below), where
you can choose the number of columns.

What you will see


If you are working in Page Layout (Print Layout) view and have text boundaries displayed, you
will see that the text area has been divided into four rectangles (you will have to set Zoom to
Page Width to see all four at once).
Note: If you don't have text boundaries displayed, you can select this option as
follows: In Word 2003 and earlier, check the box for “Text boundaries” on the View
tab of Tools | Options. In Word 2007, this option is at Office Button | Word
Options | Advanced | Show document content: “Show text boundaries.”
You will also see a change in the horizontal ruler.
If you are working in Normal (Draft) view, the only change you will see will be in the ruler, but
when you type you will find that your line now wraps at a shorter length. For this reason, make
sure that you don't have very large paragraph indents. If one of your styles, for example, has a
one-inch indent both left and right (the default formatting for the Block Text style), there won't be
much left of it in a column less than three inches wide!

Completing the setup


At this point, you will still have only 0.5" between columns. To change this to 0.6", you will need to
visit the Columns dialog. You can access it from the Format menu or Page Setup group on the
Ribbon, as described above, but a quick way to access it is from the ruler: mouse over the space
between columns until your pointer changes to a double-headed horizontal arrow and the
ScreenTip says “Left Margin,” “Right Margin,” or “Move Column”; then double-click.
Check the box for “Equal column width.” You'll notice that all the columns except Column 1 are
now dimmed. Use the spin button to change the Spacing 0.5" to 0.6" (note that Word adjusts the
Width automatically).
You've done all you need to do for now, but take a look around if you like before you OK out of
the dialog. Notice that, if you don't choose “Equal column width,” you can change each column
individually, along with the space between columns. You can also put a line between columns if
you like; this line is of a fixed weight (which cannot be changed), but you can have it in any color
you like, so long as it's black.

Working with snaking columns


You can now begin entering text. You will start typing in the first column. When it is filled, text will
flow into the second column. If you're editing text near the top or bottom of a column, the constant
text reflow may be distracting (and Word may find it challenging to update the display accurately).
In such cases, you may find it easier to work in Normal (Draft) view, where you can type in a
single long column.
This is all very well if you're typing continuous text, such as a newsletter article, but this is
supposed to be a brochure, so you probably have several distinct portions. You may want to work
in the second or third or fourth column before you finish the first. So how do you get there? Insert

34
a column break with Ctrl+Shift+Enter. This will take you to the top of the next column. Note that
column breaks, like page breaks, inherit their formatting from the following paragraph; this can
sometimes be a problem. Also, sometimes you will eventually fill the first column so full that there
is no need and indeed no room for a column break; in that case you may have to delete it. A
column break in a filled column can be difficult to see in Page Layout (Print Layout) view,
however, so you may need to switch to Normal (Draft) view to select and delete it.

Multicolumn sections in single-column documents


Sometimes you will want to divide just a portion of your document into more than one column.
This is useful for long, narrow lists that would otherwise waste a lot of paper. Since columns are a
section property, you will need to insert section breaks before and after the text you want to divide
into multiple columns. Because you want the multicolumn section to be on the same page with
the single-column text, these will need to be Continuous section breaks.
Although you can insert these breaks manually, there is an easier way. If you wait till you have
typed some or all of the text you want to format into multiple columns, plus at least one paragraph
(it can be empty) of the following single-column text, then all you have to do is select the text to
be multicolumn and choose the desired number of columns using the Columns button or dialog.
Word will take care of inserting the section breaks for you.
Note: If you need to insert a break manually, do it as follows: In Word 2003 and
earlier, use Insert | Break and choose Continuous under “Section break types” in the
Break dialog. In Word 2007, this dialog is available (as a gallery) via Page Layout |
Page Setup | Breaks.
Whenever you have a multicolumn section in the middle of a page, Word will automatically
balance the columns for you. If you want the columns to break differently (that is, unevenly), you
can either insert a column break (Ctrl+Shift+Enter) or control text flow using the “Keep with next”
and/or “Keep lines together” paragraph properties.
If a multicolumn section ends a page (because you have inserted a Next Page section break or a
page break or formatted the next paragraph as “Page break before” or used “Keep with next” to
force text to a new page), columns will not be balanced unless you insert a Continuous section
break in addition to whatever other break you have used.

Some snaking column gotchas


There are a few limitations and danger areas you should be aware of when working with columns.

Columns within columns


When you have divided your document or a portion of it into multiple columns, you can do almost
everything you can do in a single-column document or section. You can use all the normal
paragraph formatting (including borders), you can insert tables, floating or inline graphics, text
boxes, equations, and so on. The only thing you can't do is have multiple columns within a
column. Not even if you use a text box, since columns aren't permitted in text boxes, either. If you
need to have multiple columns within a column, you will have to use either a table or tabs to align
the columnar material.

Footnotes
Another limitation of columns is that they don't play well with footnotes. Footnotes in a
multicolumn document will be wrapped to the column width. Moreover, if the footnote occurs in a
multicolumn section in a single-column document, that section will insist on being on a page by
itself even though you have used Continuous section breaks before and after it.
The workaround for this is so clumsy that you may well decide it is not worth it, but if you must
combine footnotes with columns and insist on full-width footnotes (and especially if the

35
multicolumn section is part of a primarily single-column document), here's how to solve the
problem:
1. 1. Insert the footnote in a single-column section as close as possible to the
desired location of the actual footnote reference mark (so that the footnote will be on
the same page and in the correct order).
2. 2. Where you want the footnote reference mark, insert a cross-reference to the
number of the footnote you just inserted. In Word 2003 and earlier, do this with
Insert | Reference | Cross-reference | Reference type: Footnote; Insert reference
to: Footnote number (formatted). In Word 2007, the Cross-reference dialog is
accessed via References | Captions | Cross-reference or Insert | Links | Cross-
reference.
3. 3. Select the actual footnote reference mark (in the single-column text) and
format it as Hidden (Ctrl+Shift+H).

Headers and footers


This is not a problem with columns specifically, but whenever you have a short section in the
middle of a page (which often happens when you use columns for just a portion of a document),
you may develop problems with page numbering or other header/ footer-related aspects. That's
because headers and footers are a section property. Your multicolumn section has a header and
footer, but because it isn't at the top of the page, there is no way to access its header; because
it's not at the bottom of the page, you can't get to its footer. If you suspect that header/footer
problems are originating in these inaccessible locations, you have little choice but to remove one
or both of the Continuous section breaks, deal with the problems, and then restore the breaks by
selecting the text and reapplying the column formatting. Alternatively, using the information in the
section above, you could force the multicolumn section to a page of its own (temporarily) by
inserting a footnote! Or, more prosaically, you could temporarily insert a page break. Fix the
header or footer, then delete the footnote or page break.

Headings spanning columns


If you want a heading to span all of your columns, you need only leave it in the single-column
section before your multicolumn section. If there isn't a single-column section there already, you'll
need to create one. This is easily done by selecting the heading paragraph, clicking on the
Columns button on the Standard toolbar or Page Layout tab, and selecting 1 column; Word will
then create the necessary section breaks for you.
But what if you want a heading to span just some of the columns? In our four-panel brochure
example, suppose you want text to span two of the four columns. Once you have four columns,
you can't redivide just part of the page into two or three columns. You will therefore need to put
your heading text into a text box or frame and position it as needed (the problems of positioning
text boxes and frames could provide material for another article, so I won't go into that here).
Whether you use a frame or a text box, it will have a border by default. Remove this as follows:
Remove a border from a frame using the Borders and Shading dialog. Access this
dialog from the Format menu in Word 2003 and earlier. In Word 2007, click the arrow
beside the border button in the Paragraph group on the Home tab. In the dialog, choose
None. Alternatively, choose No Border from the Borders palette or menu accessed via
the button on the Formatting toolbar in Word 2003 and earlier or in Home | Paragraph
in Word 2007.
Remove the border from a text box in Word 2003 and earlier by selecting No Line on the
Colors and Lines tab of the Text Box dialog, accessed by double-clicking the edge of
the text box. In Word 2007, selecting a text box will display the contextual Text Box

36
Tools Format tab; in the Text Box Styles group, click Shape Outline and choose No
Outline.
If you use a frame, it doesn't seem to matter whether you set wrapping to None or Around. For a
text box, the default wrapping style in many versions is None of In Front of Text, which will not
work (nor will Through). Any other wrapping style seems to be satisfactory. You will need to
experiment with the other layout options to find which ones work best for your situation.
You may want to wait till you're fairly far along in entering text before you insert a text box or
frame because the effect of doing this is to reduce the text boundaries to the amount of text you
have entered (instead of showing the four rectangles you saw when you first created the
columns). This can be rather disconcerting.

Summary
Avoid text box columns. Use snaking columns when you need text to flow from one column to
another, and table or tab columns when you don't. Table columns are especially good for things
like opera librettos, where you need the text in the original score and the translation to line up with
each other vertically.

37
Keeping a table together on one page
I'm starting a table near the bottom of a page, so I'd rather have the entire table on the next page
instead of being broken over two pages (it's not too long to all fit on one page). Is there any way
to do that without inserting a manual page break?

Article contributed by Suzanne Barnhill

It's best to avoid manual page breaks in documents wherever possible, and luckily this is usually
easy to do with paragraph formatting:
In Word 2003 and earlier, use Format | Paragraph (or Paragraph… on the shortcut
menu) to open the Paragraph dialog. Select the Line and Page Breaks tab.
In Word 2007, on the Home tab, locate the Paragraph group. Click the dialog launcher
(small arrow) in the bottom right corner to open the Paragraph dialog. Select the Line
and Page Breaks tab.
On the Line and Page Breaks tab of the Paragraph dialog are several options that control text
flow:
“Widow/Orphan control” prevents a single line of a paragraph from being left alone at the
top or bottom of a page. This property is enabled by default for all styles in Word.
“Keep lines together,” as the name implies, keeps all the lines of a paragraph together.
That is, it keeps a single paragraph from being split across two pages.
“Keep with next” keeps a given paragraph with the following one. That is, it prevents the
two paragraphs from being separated across two pages (the individual paragraphs,
however, can be split internally unless “Keep lines together” is also applied). This
property is assigned by default to Word's built-in Heading 1–Heading 4 styles to ensure
that headings stay with following text.
“Page break before” causes a page break before the paragraph. Unlike a manual page
break inserted using Ctrl+Enter, however, it is not represented visually in the document
and does not inherit the properties of the following paragraph.
By judicious application of the first three properties, you can usually maneuver Word into putting a
page break where you want it without having to insert a manual page break or use “Page break
before.”

38
Note: Whenever you have “Keep with next,” “Keep lines together,” “Page break
before,” or “Suppress line numbering” enabled for a given paragraph, you will see a
small black square bullet in the left margin. If you double-click on this bullet, you
will open the Paragraph dialog with the Line and Page Breaks tab displayed.
For an easier way to apply these properties to paragraphs, you can (in Word 2003 and
earlier) add toolbar buttons for them. Unfortunately, these buttons by default have no
button icon. For an add-in that contains these buttons with attractive icons, see
“Custom Toolbar Buttons.”
Things work a little differently in tables, however. In a table, the “Keep lines together” and
“Widow/Orphan control” properties have no effect at all. To keep a table together on one page,
you must perform two actions:

1. Prevent rows from breaking internally.


In Word 97 and earlier, open the Table | Cell Height and Width dialog and
select the Row tab. Clear the check box for “Allow row to break across pages.”
In Word 2000, 2002, and 2003, open the Table | Table Properties dialog and
select the Row tab. Clear the check box for “Allow row to break across pages.”
In Word 2007, on the Table Tools | Layout tab of the Ribbon, locate the Table
group and click Properties. In the Table Properties dialog, select the Row tab.
Clear the check box for “Allow row to break across pages.”
Note: The choice of whether rows are allowed to break is strictly an either/or
proposition. If you do allow a row to break, it can break anywhere; as mentioned,
“Widow/Orphan control” and “Keep lines together” are ignored, so the only way to
force a table to break only between paragraphs is to make sure each paragraph is in a
separate row.
2. Keep rows together. Select the entire row and enable the “Keep with next” property. Do
this for every row of the table except the last.

Although it is not relevant to a one-page table, note that “Page break before,” when applied to a
table row, does not split a table as a manual page break (inserted with Ctrl+Enter) does. This
means that repeating heading rows will continue to be repeated and the table can continue to be
treated as a single table. For information on controlling page breaks in tables longer than a page,
see “How do I control where the page breaks will fall in a table that extends over several
pages?”

39
40
Maximising the performance of Word tables

Article contributed by Dave Rado

1. As a user

2. In code

To return to top, press Ctrl+Home, or use Alt + Left Arrow to Go Back)

As a user
1. Working in Normal view when you can helps, especially if you turn off “Background
repagination” (Tools + Options + General). Whatever you do, though, tables in Word 2000 and
higher are a lot slower in most respects than in Word 97 – an unfortunate by-product of the new
table engine created so that Word tables could be fully HTML-compatible.

2. If using Word 2000 and above, select Table | Table Properties | Options, and turn off the
checkbox: “Automatically resize to fit contents”. As well as slowing tables down considerably, this
setting gives (usually) undesirable results, but unfortunately is automatically switched on in all
new tables.

3. Don't create a single row containing a large amount of text. I have seen many tables
containing rows which (with non-printing characters displayed) look something like this:

Figure 1: A badly laid out table row (shown with non-printing characters

41
and table gridlines visible)

Apart from anything else, laying out table text as shown above makes it a complete nightmare to
get everything to line up, which defeats the object of using a table in the first place, the great
strength of tables being that they line text up automatically if used properly. But in addition, rows
containing many paragraphs slow tables down.

So create a separate row for each logical element of the table, as shown in Figure 2. Note that if
you don't want horizontal borders between some of the rows, you don't have to have them; so
not wanting borders is not a reason to add paragraphs instead of adding rows:

Figure 2: How the row in Figure 1 should have been laid out –
as six separate rows, but with no horizontal border between the rows

4. Break long tables up (use several smaller tables rather than one very long one),
separating the “sub-tables” with headings. So rather than, for instance, creating something like
this:

Figure 3: Avoid putting your headings inside your tables

... split your tables up into logical sub-tables instead, putting your headings outside the tables
(using Heading styles), like this:

42
Figure 4: Put your headings outside your tables

5. Avoid using merged cells as much as possible: wherever you can get away with it, remove
unwanted borders instead.

6. In Word 2000 and above, use “text-wrapped” tables only when really necessary. Set “text-
wrapping” to “None” whenever you can. For more on text-wrapped tables, see: Table basics.

7. In Word 2000 and above, if your tables contain graphics, make them inline where possible.

In code
1. If using Word 2000 and above, turn off “Automatically resize to fit contents” for all tables:
Selection.Tables(1).AllowAutoFit = False

Whatever you do, though, tables in Word 2000 and higher are a lot slower in most respects than
in Word 97 – an unfortunate by-product of the new table engine created so that Word tables could
be fully HTML-compatible (but see 5. and 7. below for an astonishing exception to this rule).

2. 2–7 above apply to tables created with code as well. In the case of switching views and
turning off background repagination, it is polite to the user to leave their settings as you found
them, i.e.:
Dim ViewType As Long, PaginationSetting As Boolean
ViewType = ActiveWindow.View.Type
PaginationSetting = Options.Pagination
'rest of your code
Options.Pagination = PaginationSetting
ActiveWindow.View.Type = ViewType

Unfortunately, even with ScreenUpdating switched off, the screen flickers when you change
views. The only way to prevent this is to use the the LockWindowUpdate API (which is beyond
the scope of this article, but a Google search will turn up details on it). So it's only worth bothering
to change views for large tables.

3. If you are putting data into a Word table using code (e.g. if you are reading it from a
database), you will get much better performance if you initially put the data into the Word
document as tab-delimited text, and then convert the text to a table at the very end. For example
(the following code sample requires you to set a reference to DAO, and also assumes you have

43
the Northwind sample database installed – it is one of the sample databases supplied with Office,
so if it is not already installed on your system, you can re-run Setup in order to install it ):
Sub GetDataIntoTable()

Dim db As Database, rs As Recordset, MyRange As Range, i As Integer


Set db = OpenDatabase(Name:= _
"c:\program files\microsoft office\office\samples\northwind.mdb")
Set rs = db.OpenRecordset(Name:="Shippers")

Set MyRange = ActiveDocument.Content


MyRange.Collapse wdCollapseEnd

MyRange.InsertAfter Text:=rs.Fields(1).Name & vbTab & rs.Fields(2).Name & vbCr


Set MyRange = ActiveDocument.Content
MyRange.Collapse wdCollapseEnd
For i = 0 To rs.RecordCount - 1
'Insert the data as tab-delimited text
MyRange.InsertAfter Text:=rs.Fields(1).Value & vbTab & rs.Fields(2).Value & vbCr
rs.MoveNext
MyRange.Collapse Direction:=wdCollapseEnd
Next i
rs.Close
db.Close

'Now convert to table


MyRange.Start = ActiveDocument.Range.Start
MyRange.ConvertToTable

Set db = Nothing
Set rs = Nothing

End Sub

If some cells in your table need to contain more than one paragraph (or to contain manual line
breaks), separate those “paragraphs” or “lines”, initially, with a dummy delimiter such as a
comma or a dollar sign; and then do a Find and Replace at the end (after converting the text to a
table), to replace the delimiter with a paragraph mark or manual line break, as desired. For a
code sample that illustrates this technique, see: How to generate a table of samples of every
font on your system.

4. If for some reason you can't insert your text in tab-delimited format and convert to table at
the end, then don't build up your table as you go by adding a row at a time. Instead, work out in
advance the total number of rows that you'll need (e.g. by reading all your values into an array
before inserting any of them in the document) and then create the entire table in one go; e.g.:
Set oTable = ActiveDocument.Tables.Add(Range:=MyRange, _
Numrows:=1000, numcolumns:=4)
'Word 2000 only:
oTable.AllowAutoFit = False

5. If inserting text, use ranges rather than selections (as illustrated in the above code
sample): and also, use characters such as vbCr and vbTab to allow you insert as much text as
possible with a single statement – again, as illustrated in the above code sample. For instance:
MyRange.InsertAfter Text:=rs.Fields(1).Value & vbTab & rs.Fields(2).Value & vbCr

... runs much faster than:


Selection.TypeText Text:=rs.Fields(1).Value
Selection.TypeText Text:=vbTab

44
Selection.TypeText Text:=rs.Fields(2).Value
Selection.TypeParagraph

6. If inserting a large amount of text into the document, make sure background spelling and
grammar checking are switched off.

At the end of your macro, out of politeness to the user, switch the settings back on if they were on
to start with. Also, if you know that the inserted text won't need to be spelling or grammar
checked, you can mark the inserted range as already checked, without marking the rest of the
document. (Thanks to Greg Chapman for this tip).
Dim SpellSetting As Boolean, GrammarSetting As Boolean, _
MyRange As Range

SpellSetting = Options.CheckSpellingAsYouType
GrammarSetting = Options.CheckGrammarAsYouType

With Options
.CheckSpellingAsYouType = False
.CheckGrammarAsYouType = False
End With

'Insert your text, e.g.


Set MyRange = Selection.Range
Selection.InsertFile "C:\Temp\Temp.doc"
'Or insert it from a database, whatever

'If you know that it's safe to do so, mark the inserted text as already checked,
'but don't mark the text that you didn't insert. If inserting from a database,
'set a range to the inserted text and operate on that range.
'If using Selection.InsertFile, use the following:

MyRange.End = Selection.End
With MyRange
.SpellingChecked = True
.GrammarChecked = True
End With

'Rest of your code, and then at the very end:


With Options
.CheckSpellingAsYouType = SpellSetting
.CheckGrammarAsYouType = GrammarSetting
End With

7. Applying manual formatting is very resource-hungry – apply predefined styles instead.

8. When cycling through table cells, never refer to a table cell by its coordinates; as that is
horrendously slow, because it forces Word to calculate from scratch, for every single cell, where
in the document the cell in question actually is.

And don't move selection from cell to cell, as this will also slow your code down dramatically.

Whilst it is much faster to cycle through the Cells collection, as in:


Sub OperateOnEveryCellUsingTableObject()

Dim oCell As Cell


For Each oCell In Selection.Tables(1).Range.Cells
oCell.Range.Text = "Hi there"
Next oCell

45
End Sub

... a much faster method still (with screen updating switched off) is to select the table, in code,
and then cycle through the cells within the selection – don't ask me why this should be faster, but
it is:
Sub OperateOnEveryCellInSelectedTable()

Dim oCell As Cell

Application.ScreenUpdating = False
Selection.Tables(1).Select
For Each oCell In Selection.Cells
oCell.Range.Text = "Hi there"
Next oCell
Application.GoBack
Application.ScreenUpdating = True

End Sub

When I timed the above macros in Word 97 and in Word 2000, using a 350-row, 5-column table,
the results were very interesting (I've rounded the results to 1 decimal place):
Word 97 Word 2000

OperateOnEveryCellUsingTableObject 38.5s

53.8s

OperateOnEveryCellInSelectedTable 5.3s

4.5s

The above results were obtained with a table created in Word 97. If the table was created in Word
2000 (and if AllowAutoFit was switched off), then using the Table object became significantly
faster in Word 2000 (though not in 97); but was still far slower than using a Selection object. If the
document was created in Word 2000 and then saved in Word 97, the results were similar to the
above.

I have no theories to explain these results, but they are easy to reproduce. Tests by colleagues
who have access to Word 2002 gave broadly similar results to Word 2000.

Turning off screen updating made no difference to the speed of the


OperateOnEveryCellUsingTableObject() macro, although it dramatically speeded up the
OperateOnEveryCellInSelectedTable() macro.

9. When operating on specific rows, or comparing the contents of adjacent rows, use the Row
object, as in the code samples at Deleting duplicate rows in a table.

10. If you want to operate on the cells in a specific table column, you can't cycle through the
cells within the column's Range – Ranges and Columns simply don't mix. Crazily, a table
column's Range contains many cells that are not actually within the column. This must once have
seemed like a good idea to someone at Microsoft, probably because they were suffering from a
bad hangover at the time! There is a certain pedantic logic to it: a column's range contains all the
cells starting from the top of the column, moving through the table from left to right along each
row, until you get to the bottom of the column. From a usability perspective this was a nightmarish

46
design decision, though, and well worth emailing mswish@microsoft.com about.

By far the fastest way of operating on a specific column is to select it and then cycle though the
selected cells, as in:
Sub OperateOnSelectedColumn3()

Dim oCell As Cell


Application.ScreenUpdating = False
'Select the third cell in the first row of the table
Selection.Tables(1).Cell(1, 3).Select
'Select column 3
Selection.SelectColumn
'Operate on the cells in column 3
For Each oCell In Selection.Cells
oCell.Range.Text = "Hi there"
Next oCell
Application.GoBack
Application.ScreenUpdating = True

End Sub

Note that you cannot safely use the Columns object to specify which column you want to select,
as in:
Selection.Tables(1).Columns(3).Select

.. because that gives an error message: “Cannot access individual columns in this collection
because the table has mixed cell widths”, either if there are any merged cells, or even if any cell
anywhere in the table has a slightly different width than the rest of the cells in the same column!
So for all practical purposes, the Column object is completely useless – another design decision
resulting from far too many Tia Marias laced with vodka, and well worth an email to
mswish@microsoft.com.

If there might be merged cells in row 1 of the table, you could select the third cell in the last row of
the table instead, and then select the column, rather than using the first row:
Dim oRow As Row, oCell As Cell
Application.ScreenUpdating = False
Set oRow = Selection.Tables(1).Rows.Last
oRow.Cells(3).Select
Selection.SelectColumn
For Each oCell In Selection.Cells
oCell.Range.Text = "Hi there"
Next oCell
Application.GoBack
Application.ScreenUpdating = True

Instead of selecting the column you could cycle through every cell in the table, operating on those
cells whose ColumnIndex property matches the column you want, as follows:
Sub OperateOnColumn3UsingRanges()

Dim oCell As Cell


For Each oCell In Selection.Tables(1).Range.Cells
If oCell.ColumnIndex = 3 Then
oCell.Range.Text = "Hi there"
End If
Next oCell

47
End Sub

... but this is not only much slower than selecting the column, but also, if there are any
horizontally merged cells in the table, the ColumnIndex property gives undesirable results.

When I timed the above macros in Word 97 and in Word 2000, using a 350-row, 5-column table,
the results on my machine were as follows (I've rounded the results to 1 decimal place):
Word 97 Word 2000

OperateOnColumn3UsingRanges 7.3s

10.7s

OperateOnSelectedColumn3 0.7s

1.1s

The above results were obtained with a table created in Word 97. If the table was created in Word
2000 (and if AllowAutoFit was switched off), then the OperateOnColumn3UsingRanges macro
became significantly faster in Word 2000 (though not in 97); but was still far slower than using a
Selection object. If the document was created in Word 2000 but then saved in Word 97, the
results were similar to the above.

As with 7. above, I have no theories to explain these results, but they are easy to reproduce.
Tests by colleagues who have access to Word 2002 gave broadly similar results to Word 2000;
and again, turning off screen updating made no difference to the speed of the
OperateOnColumn3UsingRanges() macro, although it dramatically speeded up the
OperateOnSelectedColumn3() macro.

11. If formatting the borders and shading of a table, it is far more efficient, and can speed
up your code dramatically (even in Word 97), if you execute the built-in
FormatBordersAndShading dialog (without displaying it), than it is to use “native VBA” Methods
to do the formatting. This trick also greatly reduces the risk of getting “Formatting too complex”
error messages.

In essence, this is because you can execute many commands simultaneously using the dialog,
whereas, using VBA methods, you have to execute one statement at a time, and wait for one to
finish before the next can start.

For a more detailed discussion of the principles behind this, and for some code samples to get
you started, see #2 at Getting help with calling Word's built-in dialogs using VBA (and why
doing so can be much more useful than you'd think), in the section: “Why use built-in
dialogs?”.

12. If doing a great deal of formatting of tables, then even all of the above tricks combined
may not prevent you from getting the odd “Formatting too complex” error message.

Periodically clearing the Undo buffer can help prevent this:


ActiveDocument.UndoClear.

Make sure you have turned screen updating off. If that isn't sufficient, the LockWindowUpdate
API (which is beyond the scope of this article, but a Google search will turn up details on it) is
more efficient still, as is making the application invisible.

48
If you still get “Formatting too complex” error messages, try saving the document periodically;
or as a last resort (in really huge tables), periodically save the document, close it and open it
again.

If you use all these tricks, you will find that the performance of tables is not an issue, even in
Word 2000 and higher.

49
How can I resize a table to fit the page's width?
Word 2000
In Word 2000 you can select Table + Properties, click on the “preferred width” checkbox; where it
says “Measure in”, change it to “percent”, and in the width spinbox, type 100%. The relative
column widths are preserved in the resized table.

Or if you want to do it programmatically, you can use:


Selection.Tables(1).PreferredWidthType = wdPreferredWidthPercent
Selection.Tables(1).PreferredWidth = 100

Word 97
In Word 97, you can select the entire table, and on the Column tab of Table | Cell Height and
Width, type "a" and press the down arrow. The box will fill with the word “Auto”; OK out, and the
table is resized to the margin width. Unfortunately (unlike Word 2000), the columns in the resized
table are all equal widths.

Alternatively, if you click in any cell (with nothing selected) and follow the same procedure, the
column which the insertion point is in will be resized so that the table fits the page margins –
without the other column widths being affected.

If you want to preserve the relative column widths when you resize the table, (as one generally
does), you'll need a macro to do the job:

Sub MakeTableFitPageSize()

Dim myTable As Table


Dim OriginalRange As Range
Dim oRow As Row
Dim oCell As Cell
Dim UsableWidth As Single
Dim TableWidth As Single
Dim CellNo As Long

If Selection.Tables.Count = 0 Then

50
MsgBox "Please put your cursor inside a table and try again", vbInformation
Exit Sub
End If

Application.ScreenUpdating = False
System.Cursor = wdCursorWait

Set OriginalRange = Selection.Range


Set myTable = Selection.Tables(1)

myTable.Rows.SetLeftIndent _
LeftIndent:=0, RulerStyle:=wdAdjustNone

'Calculate usable width of page

With ActiveDocument.PageSetup
UsableWidth = .PageWidth - .LeftMargin - .RightMargin
End With

'Calculate width of top row, on assumption this will be


'the same as table width

On Error Resume Next

For CellNo = 1 To myTable.Rows(1).Cells.Count

If Err = 5991 Then


MsgBox "This macro doesn't work with tables that have vertically merged cells", _
vbInformation
GoTo CleanUp
Else If Err Then
MsgBox Err.Description, vbInformation
GoTo CleanUp
End If

TableWidth = TableWidth + myTable.Rows(1).Cells(CellNo).Width


Next CellNo

On Error Goto 0

'Calculate and assign width of each cell in each row, such that the cell width relative
'to the table's width stays the same as before. Do it for each row individually rather than
'for a column at a time- otherwise the macro won't work
'if any of the rows contain horizontally merged cells

For Each oRow In myTable.Rows

For Each oCell In oRow.Cells


oCell.Width = (oCell.Width) * (UsableWidth / TableWidth)
Next oCell

Next oRow

OriginalRange.Select

Cleanup:

51
'Clear variables from memory
Set myTable = Nothing
Set OriginalRange = Nothing
Set oRow = Nothing
Set oCell = Nothing
UsableWidth = 0
TableWidth = 0
CellNo = 0

System.Cursor = wdCursorNormal
Application.ScreenUpdating = True

End Sub

52
How to centre a left-justified table (or left or right-justify a centred one)

Article contributed by Dave Rado

Word 97
Click anywhere in the table, and on the Table menu select Cell Height and Width. (Why “Cell
Height and Width”, you may ask? Good question. Word 2000 is more logical).

Where it says Indent from Left, make sure it's set to 0. Where it says Alignment, set it to Left,
Centre, or Right as desired.

Word 2000
Click anywhere in the table, and on the Table menu select Table Properties. Where it says
Indent from Left, make sure it's set to 0. Where it says Alignment, set it to Left, Centre, or Right
as desired.

Using VBA
In both versions of Word, the VBA for this is:

With Selection.Tables(1).Rows
.LeftIndent = 0
.Alignment = wdAlignRowCenter
'or set whichever alignment you want
End With

53
54
Printer-friendly version:
How to fix the Word 2000+ Cell Alignment buttons

Article contributed by Dave Rado

In Word 2000+, both on the Tables and Borders toolbar, and on the shortcut menu that you see
when you right-click a table-cell, the Cell Alignment buttons are almost unusable, if you want to use
Word properly. In Word 97, there were three Cell Alignment buttons: “Align Top”, “Center
Vertically” and “Align Bottom”.

Unfortunately, out of the box, Word 2000+ provides the buttons shown on the right, instead. These
work by applying manual paragraph formatting to your text, in order to apply the horizontal
alignment you select (this is especially annoying if your text is justified). Fortunately you can

replace the Word 2000 buttons with the Word 97 ones:

1. Select Tools + Customize.

2. Drag the Word 2000+ “Cell Alignment” menu button off the Tables and Borders toolbar.

3. On the Commands tab of the Customize dialog, select “Table” in the left pane, and drag the
“Align Top”, “Center Vertically” and “Align Bottom” buttons from the right pane onto the Tables
and Borders toolbar. Close the Tables and Borders toolbar.

4. On the Toolbars tab of the Customize dialog, scroll down the list of toolbars, and click on
“Shortcut menus”. The Shortcut Menus toolbar will appear.

5. Pull down the “Tables” menu on the Shortcut Menus toolbar; select the “Table Cell” submenu,
and drag off the Word 2000+ Cell Alignment button.

6. Select the Commands tab of the Customize dialog, select “New Menu” in the left pane,

55
then select the “New Menu” button in the right pane and drag it onto the Shortcut Menus toolbar,
under the “Table Cell” submenu, to the position where the Cell Alignment button was before you
dragged it off.

7. Right-click on your new button, and where it says “Name”, overtype the words “New menu”
changing it to say “Cell Alignment”.

8. On the Commands tab of the Customize dialog, select “Table” in the left pane, and drag
the “Align Top”, “Center Vertically” and “Align Bottom” buttons from the right pane onto your new
“Cell Alignment” button.

9. With the Ctrl key held down, drag to copy the new “Cell Alignment” menu button from the
“Table Cell” shortcut menu onto the “Table Text”, “Tables” and “Whole Tables” shortcut menus.

10. Drag the Word 2000 Cell Alignment menu button off the “Table Text”, “Tables” and “Whole
Tables” shortcut menus.

11. Holding the Shift key down, select File + Save All, and save the changes to your Normal

56
template.

Note: An even safer plan is to create an add-in first and make the customisation in your add-in,
rather than in Normal.dot. That way, if you ever have to delete Normal.dot, you will not lose your
customisation. For more on this see: What do Templates and Add-ins store?

57
Is there a way to add custom table formats to the Table Autoformat list?

Article contributed by Dave Rado

In Word 2002, you can use (the somewhat ironically named) Table Styles. Unfortunately, if you do
so, they do not apply paragraph styles to the text within your tables; they apply manual formatting
instead – which defeats the object of using styles. I would therefore not use this feature in
documents of any importance.

The simplest method of applying your own table formats when creating new tables is to create
AutoText entries for each of your frequently used formats (“Titles in top row”, “Left column”,
“Both”, etc.). And this is the only solution if you don't want to write macros.

But that won't help you to format pre-existing tables (so won't help when pasting other people's
tables into your documents). There is no solution to this that doesn't involve writing macros.

The simplest way of addressing this in Word 2002 may be to define Table Styles via the user
interface (“may be”, because the dialog may or may not allow you to define the format you want);
then write a macro that offers the user a list of your corporate table styles to choose from, applies
the one they chose, and then formats the text in the table using the appropriate paragraph styles. If
you call your macro TableAutoFormat, it will intercept the built-in command, so that when the user
selects Table + Table AutoFormat, your macro will automatically run.

In Word 97 and 2000, if (and its a massive if) your company's standard table formats closely
resemble one of the built-in ones, you can use a similar approach, with the addition of whatever
code is needed to tweak the built-in format so that it conforms with your standard format.

But most companies' table formats that I come across don't bear any resemblance to the Microsoft
ones, so for most companies, the only really satisfactory way of addressing this is to write your
own TableAutoFormat macro from scratch (again, call your macro TableAutoFormat, so that it
intercepts the built-in command), and install it as an add-in. You will need to use all the tricks
covered in: Maximising the performance of Word tables, in order to ensure that your code runs
quickly. Also, keep your user dialog as simple as possible – for instance, this is an example of one
I've created in the past:

58
As an aside, Romke Soldaat's article Table Styles is sometimes linked to from the newsgroups
when this question is asked; but in fact that article does not cover how to create your own table
formats; instead, it covers how to assign meaningful names to Microsoft's built-in table formats.

I tried to use the { =SUM(ABOVE) } formula in a table but


the answer was obviously incorrect
Article contributed by Suzanne Barnhill

If you have numbers in a table column and use the Table | Formula command in Word
2003 or earlier (Table Tools | Layout | Data | Formula in Word 2007), Word by default
inserts the { =SUM(ABOVE) } formula field. This is quite often what you want: to sum the
numbers in the column above the current cell. But often the result is obviously
erroneous. There are two possible reasons for this:

59
1. If you are using Word 97 or earlier, the { =SUM(ABOVE) } field does not work for
more than 85 rows. (This is not a problem with { =SUM(LEFT) } because the
number of columns is limited to 63 anyway.)

2. A much more common problem, in all Word versions, is that Word stops counting
when it gets to an empty cell or one with text in it instead of a number.
To get around either of these problems, however, you can use the { =SUM( ) } field with
cell addresses. For example, to add the numeric contents of the cells in column D (let's
say there are 90 rows; the first one is a Heading Row, and #90 is the one where you
want to put the answer), disregarding empty and nonnumeric cells, you can use the
formula { =SUM(D2:D89) }.
But what if you don't know how many rows you have? Unlike WordPerfect, Word does
not display cell references in the status bar. Despite many requests for this feature, it will
likely never be provided: Word’s developers tell us that merged cells and nested tables
make the calculation so processor-intensive that constantly updating the status bar
would adversely affect Word’s performance.
There is, however, a way to get the address of a specific cell upon request. To help
Word 97 users, Microsoft provided the TableCellHelper macro in the Macros8.dot
template in the Macros folder of C:\Program Files\Microsoft Office\Office\. Although
some subsequent Word versions have included templates containing macros, none of
these has contained this macro. You can, however, download the Macros8.dot template
by following this link. This macro still works in all versions, including Word 2007.
When you run this macro, a message box reports the address of the cell you're in and
the total number of rows and columns in the table.
The easiest way to make this macro available in every document you create is to copy it
into the Normal template, as follows:

 Word 2003 and earlier: With the Macros8.dot template open, go to the Tools |
Templates and Add-ins dialog, click Organizer… and select the Macro Project
Items tab. You'll see two boxes labeled “Macro projects available in.” The one on
the right will say “Normal.dot (global template).” The one on the left will say
“Macros8.dot (Template).” When you select the TableCellHelper macro in the list
on the left, the Copy button arrow will point right, and the labels above the boxes
will say “In Macros8.dot” and “To Normal.dot.” Click the Copy button, and you will
have added the TableCellHelper macro to the Normal template. There is another
macro called TableCellHelper.AddToStd which, when run, will place a
TableCellHelper button on the Standard toolbar. Since this button, as inserted, is
entirely blank, so you can't even see where it went, I don't recommend copying
this macro.

 Word 2007: On the View tab, locate the Macros group, click on the Macros
button, and choose View Macros. Click on Organizer… This opens an
Organizer dialog similar to the one in Word 2003 and earlier; from here you can
follow the instructions (above) for those versions.
As an alternative to copying the macro to your Normal template, you could create a new
template and store it in Word's Startup directory (as defined in Tools | Options | File

60
Locations). Storing it there makes it an add-in (or global template). You can then copy
the macros to your add-in.
If you need to use the TableCellHelper macro very often, you'll want some easier way to
do it than by opening the Macros dialog, selecting TableCellHelper, and clicking Run.
So you may want to add it to the Table menu or a toolbar in Word 2003 or earlier or to
the QAT in Word 2007. Do this as follows:

 Word 2003 and earlier: Open Tools | Customize. On the Commands tab, scroll
down the list of Categories till you see Macros. Find the TableCellHelper macro
(if you copied the TableCellHelper.AddtoStd macro, be careful not to select this
one). Select the TableCellHelper macro item and drag it to the menu bar,
hovering over the Table menu item. When the Table menu opens, drop the
macro in the desired location on the menu. If you prefer to have a toolbar button
for this macro, drag it to a toolbar instead.
Note: When you add a macro to a menu or toolbar, by default it will display the long string of
text that is displayed in the Customize dialog (and no icon). This is rarely what you want.

 For a menu item, you can modify the text to be anything you like. To do this, right-click
on the menu item and change the text in the Name box.

 For a toolbar button, you will probably want an icon instead; right-click on the button,
choose Change Button Image, and select one of the icons offered (I used the big yellow
question mark). Then right-click again and choose Default Style. Note that the “default
style” for a toolbar button is an image only; for a menu item it is an image and text.

 The menu of actions you can use to modify a menu item or toolbar button (which can
also be accessed by selecting the menu item or toolbar button and clicking Modify
Selection in the Customize dialog) also includes Copy Button Image (to copy the icon
from another button), Paste Button Image (to paste it on your new button), and Edit
Button Image, which allows you to create your own custom button icon. (For more on
adding buttons to menus and toolbars, see “How to assign a Word command or macro to
a toolbar or menu.” For a library of button images, see “Assigning custom button faces to
your toolbar and menu buttons.”

 Word 2007: Right-click on the QAT choose Customize Quick Access


Toolbar… In the Word Options | Customize dialog, choose Macros under
“Choose commands from:” and select the TableCellHelper macro. Click Add>>
to add it to the QAT. While it is still selected, click Modify… and choose a button
image for the new button (good luck with finding an appropriate one!).
Word MVP Greg Maxey offers an improved version of the TableCellHelper macro at his
Web site.
For another workaround, see the following article: “How to get a formula field to total an
entire table column, even if some cells in the column contain text or are blank.”

61
How to get a formula field to total an entire table column, even if some cells in the
column contain text or are blank

Article contributed by Dave Rado

The big problem with using the { =SUM(ABOVE) } field in Word (by selecting Table + Formula) to
sum a table column, is that if there are any blank cells in the column, or any cells containing text,
the formula only sums the cells below the first non-numeric cell it encounters. Another problem is
that it can only total a maximum of 85 cells.

One workaround is to specify the row and column numbers in the formula; for example, to sum
rows 1-20 of the fourth column (column D), you could use { =SUM(D1:D20) }. The big problem
with that, though, is that such a formula would need to be amended the moment you added or
deleted any rows (and most users wouldn't remember to amend it). And unfortunately, if you
used { =SUM(D:D) } to total column D, you'd get a circular reference (the formula would include
itself in the total). However, see: I tried to use the
{ =SUM(ABOVE) } formula in a table but the answer was obviously incorrect for more
information regarding this workaround.

Another workaround is to use ToolsCalculate instead of using a formula.

The trick I use is to have the total row as a separate table, separated from the main one by a
paragraph with its Font size set to 1 point, and “Hidden” (under Format + Font), and its line
spacing set to “Multiple 0.1” (under Format + Paragraph).

Because of the 0.1 line spacing, the gap between the tables is not noticeable, even on-screen,
and even when “ShowAll” is switched on; so arguably it isn't really vital that you set the font to
Hidden; but without doing that, the gap may just be noticeable on high resolution printers.

Then use a bookmark in the SUM formula. It's a bit kludgy but it does work. One major benefit of
this strategy (for things like Invoice and Quote templates) is that the user can subsequently add
more rows to the main table simply by tabbing, and the formula will still work – which they couldn't
otherwise do.

So supposing you've created two tables (the main table and the total row table) as follows:

62
Figure 1: This is actually two tables, separated by a 1 point, 0.1 line-spaced paragraph.
As you can see, even with “ShowAll” switched on, the gap is invisible.

Select the main table, select Insert + Bookmark, call the bookmark “Table1” and click Add. (If
you had more tables of this sort you could bookmark the others with names such as “Table2”,
“Table3”, etc).

Then in the total cell, press Ctrl+F9, and within the field braces {}, insert the following formula:
{ SUM(Table1 F:F) \# "#,##0.00;- #,##0.00;''" }

“Table1” in the formula refers to the name of the bookmark you've marked the main table with.
The formula, being in a different table from the column it's totalling, wouldn't know which table you
were referencing otherwise. The F:F bit means the 6th column from the left.

The bit at the end of the formula:


;''"

... means that if there are no values in column F, don't display anything (otherwise it would
display 0.00). I learnt that trick from Word MVP Cindy Meister.

The “total” field will automatically update when you print, or go into Print Preview (provided you
have “Update fields” switched on under Tools + Options + Print); and you can also update your
fields at any time by Selecting All and pressing F9 (update fields) - which you could assign to a
Toolbar button to make it more user-friendly.

If the user might need to insert more such tables in the same document, you could make it more
user-friendly still by storing the basic table layout, as an AutoText entry; and then using a macro
to insert the AutoText entry, assign a bookmark to the main table (bearing in mind that the
bookmark name needs to be different each time, so can't be stored in the AutoText entry itself),
and insert the formula (which could not be stored in the AutoText entry, for the same reason).

Formula Fields are covered in more detail in Word's Help.

63
64
Floating objects in Word 2000 table cells are vertically
aligned wrongly
Whenever I insert a graphical object (picture, drawing object, etc.) into a Word 2000
table cell I lose the vertical formatting. The text is always aligned at the top of the cell,
instead of being centered or at the bottom of the cell. Why, and what can I do about it?
Article contributed by Cindy Meister

This problem is due to Word2000 table text being able to “wrap“” around a graphic –
and that negates the vertical cell alignment. Here's how to work around it.

When you insert a graphic of any type that “floats above the text” (can be freely
positioned on the page), it anchors itself to text within the document. (If you don't see an
anchor symbol somewhere in the left margin when a graphic is selected, turn on the
display of non-printing characters in Tools/Options/View.) When the anchor is in the
table, you see the problem described; if it's outside the table, you get the correct vertical
alignment.

1. Insert the graphic outside the table; make sure the anchor is outside the

table.
(If you can't see the anchor, click on the Show/Hide button to display non-printing
characters).

2. Right-click on the graphic.

3. Go to Format AutoShape/Layout/Advanced.

4. Activate “Lock anchor”. Now the anchor will stay with the text outside the table.

5. Drag the graphic into the table.

65
I have a “Name” column which I want to split into “FirstName”, “LastName” – how can I
do it?

Article contributed by Dave Rado

Word's sorting capability is fairly rudimentary, especially for those migrating to it from WordPerfect
(though it's surprising how many people don't realize Word can sort paragraphs, not just tables – or
maybe not so surprising, given where the item is in the menus! The ability to sort on word 2 in field
3 would certainly be very useful (in Excel as well). I believe there has been a lot of demand for this
capability to be added, so maybe it's on the way ...

But there are various things you can do in the meantime. One is, write a macro. Another is to use
Find and Replace to separate the text into fields (using tabs as the field separator). For instance, I
often use the following trick if I'm emailed a spreadsheet with a “Name” column which I want to
split into “FirstName”, “LastName”: The following assumes the column is in Excel, but of course it
could just as easily be in a Word table.

1. Select the column in Excel and paste it into a blank Word document.

2. Select the column in Word (press Alt + Left mouse click), then press Ctrl+Spacebar to remove
manual character formatting, and select Table + Convert Table to Text.

3. Use Find and Replace to replace any spaces with single ones:

In the Find what box type: ^w


(or select the "Special" button and choose "White space)
In the Replace with box type [space] (i.e. press the spacebar)
Click Replace All

4. Next, you want to replace the spaces preceding the last names with tabs, in order to be
able to convert back to a table separated by tabs.

To allow for the possibility that, somewhere in the list, there might be some middle names or
initials, select the “Use wildcards” check box in the Find and Replace dialog, and:

In the Find what box type: (<*) ([! ]@)^13

66
In the Replace with box type: \1^t\2^p
Click Replace All

That will give you the following result (with non-printing characters displayed):

For more on using wildcard searches see: Finding and replacing characters using wildcards.

Alternatively, if your original list was in the format:

Major, Alan P.

Then you don't need to use wildcards in order to insert the tabs in the right place

In the Find what box type: ,[space] (type a comma then press the spacebar)
In the Replace with box type ^t
Click Replace All

5. Select the text (Ctrl+A) and select Table + Convert Text to Table.

You should find that the Word dialog suggests 2 columns and that text should be separated at
tabs. If not that you don't have any rogue text or empty paragraphs selected at the end of the
document.

If there were any middle names or initials in the list, I fix these later by creating a MiddleName
column in Excel and putting these orphans into it.

6. Type “FirstName” and “LastName” in the two cells in the top row of your new table.

Copy your Word table, Alt+Tab into Excel, insert an additional column to the right of the “Name”
column, and paste.

Sounds convoluted and I guess it is, but it doesn't take long – I've fixed 1,000 record mail merge
Data Sources in minutes using this method.

67
68
How to convert a Word table into an Access database
Article contributed by Beth Melton

There are a couple of methods you can use for this. Using Excel, if you If you have it, is the
easiest way, and you tend to get fewer import errors in Access if you use Excel. However, if you
don't have Excel, you can convert your Word table into tab-delimited format, which you can
import directly into Access. This is still pretty easy, although it does involve a few additional steps.

Whichever method you use, make sure the first row of your table contains field names that
uniquely describe the information in each column. If it doesn’t, then place your cursor in the first
row, go to Table/Insert Rows and add your field names.

Using Excel to transfer data between Word and Access:


Copy and Paste the table onto an Excel worksheet

Open your Access database (create a new one if need be)

Select the cells in Excel and copy them

Switch to the Access database, display the Tables object list and click the Paste command

You will receive a message: “Does the first row of your data contain column headings?”.
Answer “Yes” and your Access table is created

Right-click the table, select “Rename” and change the name of the table

Tip for power users: if you know how to drag and drop via the Windows Taskbar, the procedure is
even easier.

Select the Word table

Drag and drop it into Excel

Drag and drop it onto the Tables object list in Access

Using Word Only

69
Select the Word table and go to Table/Convert Table to Text

Use the Separate the Text using Tabs option

Go to File/Save As and change the Save as Type to “Text only”. Save and close the file.

Open your Access database (create a new one if needed)

Right-click an empty area of the Tables Object list and select Import

Change the Files of Type to Text Files

Select your text file you saved earlier and work through the Import Text Wizard

Note that once you have your table in Access, you need to go to the Table design and review the
data types and field sizes assigned and make the necessary changes.

70
You can download a sample template in Word 6/95 file format (29 KB). There is an
example in it for items marked with an *asterisk. Code for automating numbering using
Word fields can be found in the MOD article "Word Fields, Part II: Numbering
Conundrums".

*Create a reverse numbering sequence in Word


Word has no provision for numbering in reverse order. But you can set up a
semiautomatic numbering sequence using a combination of formula, SET and
SEQ fields .
Example: { SET HighNr 11 }{ = HighNr - { SEQ RevNrList } }
{ = HighNr - { SEQ RevNrList } }
{ = HighNr - { SEQ RevNrList } }
Display: 10
9
8

Generate a number sequence like Excel uses to number


columns
Traditional outline numbering using alphabetic characters proceeds A...Z, AA,
BB, CC. But most people these days are so accustomed to the sequence used for
Excel columns (A...Z, AA, AB, AC) that they prefer this in their documents. It is
even a requirement for legal documents in some counties / states.
No current version of Word supports the Excel-type numbering. But it can be achieved
using SET and IF fields:

{ Quote { Set ABC { = { ABC } + 1 } }{ SET ABC2 { IF { ABC } > 26 "{ IF { =


MOD({ ABC }, 26) } = 1 "{ = { ABC2 } + 1 }" "{ ABC2 }" }" "{ ABC2 }" } }{
SET ABC1 { IF ABC1 < 26 "{ = { ABC1 } + 1 }" "1" } }{ If { ABC } < 27 "{
ABC1 \* ALPHABETIC }" "{ ABC2 \* ALPHABETIC }{ ABC1 \*
ALPHABETIC }" } }
More information on how to use fields.

Use Relative Cell References in Word table formulas


Cell references in Word formulas are always absolute: when you copy them they
paste in literally and you have to adjust them manually. Here, again, a
combination of formula, SET and SEQ fields offer a solution.
In Word 6/95, this works:

ITEM ITEM ITEM Standard Field set to generate relative cell


RESULT
1 2 3 Formula reference
3 2 4 { = A1 * 2 { Quote { Set CellNr1 "a{ SEQ

71
B1 - C1 } CellNr }" }{ Set CellNr2 "b{ SEQ
CellNr \c }" }{ Set CellNr3 "c{
SEQ CellNr \c }" }{ = { Ref
CellNr1 }*{ Ref CellNr2 }-{ Ref
CellNr3 } } }
{ Quote { Set CellNr1 "a{ SEQ
CellNr }" }{ Set CellNr2 "b{ SEQ
{ = A2 * CellNr \c }" }{ Set CellNr3 "c{
6 2 4 8
B2 - C2 } SEQ CellNr \c }" }{ = { Ref
CellNr1 }*{ Ref CellNr2 }-{ Ref
CellNr3 } } }
As in so many things, Word97's fields don't behave quite right. When you try to combine
something in the SET bookmark with the SEQ field, the SEQ field increments by 2,
instead of by 1, so you need this:

ITEM ITEM ITEM Standard Field set to generate relative cell


RESULT
1 2 3 Formula reference
{ Quote { Set CellNr1 "a{ = { SEQ
CellNr }/2}" }{ Set CellNr2 "b{ = {
{ = A1 * SEQ CellNr \c }/2}" }{ Set CellNr3
3 2 4 2
B1 - C1 } "c{ = { SEQ CellNr \c }/2}" }{ = {
Ref CellNr1 }*{ Ref CellNr2 }-{
Ref CellNr3 } } }

The QUOTE field is not necessary, but it helps to keep everything together. The SET
fields create bookmarks referenced in the formula. The SEQ fields generate the row
numbers. The first one will update as it is copied down the table; the second and third are
locked to the first by the \c switch.

*Right-align Autonumbers in a list


By default, the numbers are aligned to the left. If you click "Modify" in
Format/Bullets and Numbering you can change this. The "Alignment" list with
Left/Center/Right is easy to find. But you may be disappointed not to see an
immediate effect when you go back to your document. This may happen if the
number doesn't find enough elbow room between the indent setting and the text.
Increase the "Distance from Indent to text" setting and you should see the
numbers align to the right.

*Display millions when using CardText or DollarText number


formats
There are special formatting switches that allow you to display a number as text,
either with or without "dollars". (For more information on the number formatting

72
switches, look under Switches; field switches; number formats in Word's Help
Index.) But the program is limited to displaying the information for numbers less
than one million. In order to display amounts in the millions as text, you need to
use a combination of nested fields:
Example: { QUOTE { = SET n 1999999 }{ IF n < 1000000 "{ = n
\*cardtext }" "{ = int(n/1000000) \* cardtext } million
{ { = MOD(n, 1000000) } }{ IF r = 0 "" "{ = r \*
SET r
cardtext }" }" } \* caps \* CharFormat }
Display: one million nine hundred ninety-nine thousand nine
hundred ninety-nine
The QUOTE field keeps everything together. The number you want to work with
is bookmarked in the SET field. Then you test whether the number is greater than
one million. If it is, divide it by one million, then get the integer of this result for
the words in millions. Next, determine the remainder and get the text for it.
I can't take credit for this solution. It is the result of the combined efforts of
numerous regulars in GO MSWORD on CompuServe. Thanks for you input,
friends, as always :-)

Continuous Page Numbering across separate files


As many of us have experienced, the Master Document feature in Word is simply
not stable enough to rely on for working with large documents. If you must
manage a large document as separate files, there are some tricks you can use. For
example, using a couple of fields, you can create consecutive page numbering
across multiple files:
1. At the end of the first document insert a PAGE field; select it.
2. Format the field as "hidden".
3. Place the field in a bookmark (Word 6/95: Edit/Bookmark; Word97 and
later: Insert/Bookmark).
4. Save this file; open the next file.
5. In the header or footer, where the page number should appear, insert the
following set of fields:
6. { = { PAGE} + { INCLUDETEXT "C:\\My Book\\Chap1.doc"
Chap1Pages
\* CharFormat \! } }
Repeat the steps for each document in sequence.
Discussion: The INCLUDETEXT field can reference any document, and any bookmark
within a document. Be sure to place the document path in "double-quotes", and to use
double-backslashes. The bookmark name follows the path (Chap1Pages, in the above
example). The \* CharFormat switch forces the field result to be formatted with the font
settings in the target document, rather than bring the formatting with it (otherwise the
result would be "hidden"). The \! switch prevents the PAGE field within the bookmark
from updating to reflect the context in the target document.

73
More information on how to use fields.

Word 6/95: Place a table in a numbered list with continuous


numbering
If you insert a table (or other object) in numbered text the numbering restarts after
the table. There are a number of workarounds:
1. Use a Heading style to generate the numbering. You can use a style
near the end of the list, such as Heading 7. Simply format the style to look
like the text in the body of the document. This method works well in all
situations where you are not already using all Heading levels to outline
your document.

2. *Use SEQ fields to create the numbering. This method is very versatile,
although it will seem awkward, especially until it is set up. Creating
AutoText entries of each numbering level or sequence helps in speeding
things up and making work more intuitive. Remember, an AutoText entry
can also be assigned to a keyboard shortcut or toolbar button!
3. Place the table in a frame. The key to this method is to make sure the
frame is anchored outside the numbered list. So this method only works
well for short lists that cover less than two pages. Format the frame to
"Move with text".
4. *Place the table in a text box. The text box will not interfere with the
number flow. The drawback is that text will not flow around a text box.
Either press Shift+Enter until the following text is below the text box, or
draw an empty frame over the text box. Format the frame to "Move with
text", then anchor the text box to the frame and "Lock" the anchor. This
way the two will always move together, with the text, as the document is
edited.

74
How to link a Word table with a Word graph
Article contributed by Daryl Lucas

Suppose you want to have a graph, such as a pie chart, that is linked to formfields in a protected
document. In each formfield, the user will enter numbers. You want the graph to update to reflect
the new data. And you want to use MS Graph instead of Excel, to keep the whole thing
lightweight and self-contained.

I know that most people use Excel to create graphs in Word documents, but I like using MS
Graph. Like a compact car, it does most of what a charting tool needs to do without the expense
or heavy duty lifting of a Nimitz-class Excel chart. It's lightweight and functional.

But like Excel, it is also a completely different application, and that makes for some confusion. For
example, many new users of Word intuitively expect MS Graph charts to be updateable from
Word tables. Alas, they are not. An MS Graph graph is an embedded object. It cannot be linked
to the data in a protected table in any way whatsoever. The chart that you see gets its values
from a DataSheet that comes with the object.

But you can use the following macro to do the charting updates, and the results are far easier to
achieve and far faster to get than Excel results. You can use VBA to export the values in your
table to the DataSheet in the MS Graph object.

In English, you do this:

1. Get the values in the FormFields.

2. Open the graph for editing.

3. Put the FormField values in the appropriate DataSheet cells.

4. Update the chart.

5. Shut down MSGraph.

The code that follows does exactly that. I run it OnExit from the last FormField entered in the

75
form.
Public Sub UpdateChart()

Dim oMSGraphWrapper As Word.InlineShape


Dim oDoc As Word.Document
Dim oMSGraphObject As Object
Dim oDataSheet As Graph.DataSheet
Dim iEntry1 As Long
Dim iEntry2 As Long

Set oDoc = ActiveDocument


oDoc.Application.ScreenUpdating = False
Set oMSGraphWrapper = oDoc.InlineShapes(1)
iEntry1 = oDoc.FormFields("txtEntry1").Result
iEntry2 = oDoc.FormFields("txtEntry2").Result
oMSGraphWrapper.OLEFormat.Edit
Set oMSGraphObject = oMSGraphWrapper.OLEFormat.Object
Set oDataSheet = oMSGraphObject.Application.DataSheet

With oDataSheet
.Range("a1").Value = iEntry1
.Range("b1").Value = iEntry2
End With

With oMSGraphObject.Application
.Update
.Quit
End With

oDoc.Application.ScreenUpdating = True

Set oDataSheet = Nothing


Set oMSGraphWrapper = Nothing
Set oDoc = Nothing
Set oMSGraphObject = Nothing

End Sub

If you want to see how this works, just make sure you do three things:

1. Have a table with two numeric FormFields named txtEntry1 and txtEntry2.

2. Set at least one of the OnEntry or OnExit macros to the UpdateChart macro.

3. Set a reference to the Microsoft Graph 8.0 Object Library in the appropriate template in the
Visual Basic Editor. (Under Tools + References).

76
77
78

Potrebbero piacerti anche