Home | Tips | Library | Other Authors | Other WP Sites | Writer's Links | Contact | Site Map | Donate

Barry MacDonnell's
Toolbox for WordPerfect

Macros, tips, and templates for Corel® WordPerfect® for Windows®
© Copyright 1996-2021 by Barry MacDonnell. All Rights Reserved.

Page updated May 18, 2016

WordPerfect Tips
Main tips page | Browse more tips
Need to create some table cells that have variable widths without changing cells directly above and below that row?

Here's a trick using stacked one-row tables that look just like a single multi-row table. You can then drag any cell border to produce the width you need without affecting other rows.

Related items -

Split table cells in a particular row so that the resulting cells are equal in width

Using WordPerfect tables

WordPerfect table cells take on the width and internal vertical margin dimensions of their columns. Dragging a particular cell's vertical border to the left or right will also change the cell widths directly above and below that point in the same column. 

This is because you are adjusting the column width, not the cell width. 

But you can create cells with variable widths in any given row without affecting other rows -- if you simulate a single multi-row table by using individual tables for each row in the final design.

The tables can be positioned directly below one another on the page, in a "stack" of tables without spaces between them, and they will appear as a single table on screen and in a printout.

This is fairly easy to do -- typically, it should not take much more than 10 or 20 minutes -- and the methods below can help speed up subsequent table creation of the same type.

How to do it

The basic idea is to create a single, one-row, "model" table with the general formatting that any row in your ultimate table form should have (such as specific internal column/row margins). 

You can then quickly replicate the model into a "stack" of tables with no separation between them, creating the basic "bones" of the form. 

Then you can make any cell whatever width you wish by simply dragging the cell's vertical border leftward or rightward. 

Finally, you insert text, merge codes, etc., into the form. (You can still drag cell boundaries, join cells, or split cells to adjust the final form.)

Step 1. Create your model table with a single row and as many columns as you think you might need in any given row of the resulting table:
  • Click on Table, Create (or similar in early versions of WordPerfect), then select the number of desired columns, and use the default of 1 row. Click Create.

The maximum number of columns you can create in a table is 64.

But it is doubtful you would need this many in single-row tables: Remember that you can 
split cells later to create additional cells (i.e., columns) and/or join cells later to create fewer cells in any given row, without affecting the other areas of the final form's design.

Then you can simply drag the new vertical cell (i.e., column) boundaries to suit the data requirements of that row.

You might try a test of this method with a simple one-row, 4- or 5-column table. 

  • Next, set up some general internal formatting to use in this model table. (These will also be used in subsequent tables you will create later.)
Click in any cell, then click the "Select Table Row" icon on the table Property bar. (You can also select the entire row to select it; just be sure all cells are completely filled with black by keeping the cursor inside the cells as you drag the mouse.)

Once the table's cells are selected, click Table, Format on the top menu or on the Property bar (or right-click on the selection and choose Format). This opens the "Properties for Table Format dialog, with several tabs (Cell, Column, Row, Table, Skew).

Cell tab: If desired, set new cell margins (these will be the same as column margins in a 1-row table). Set other cell formatting here. (For locking and unlocking a cell, which should be done later after text has been entered, see here.)

Column tab: If desired, set new column margins (if not done in the Cell tab). Set other column formatting here.

Row tab: You probably will want to leave the two Row Attributes checkboxes disabled (un-ticked). You probably want to set "Lines of text per row" to "Single line" so that any text that exceeds the cell width will not wrap and expand the row's height, pushing the rest of the form downward. If desired, set new row margins. If you wish you can set row height to a fixed amount. ("Automatic" uses the current font height (plus row margins) to determine row height.)

Table tab: Here, you can adjust overall table formatting (and change the number of columns). You probably want to decide how to position the table on the page, since some forms might need to start flush with the left margin (or some other point) on the page. You probably will want to disable (un-tick) "Insert new rows automatically". (For more information on disabling a locked cell, which should be done later after text has been entered, see here.)

Click OK to return to the document.

Optional: You can select the row or just certain cells and apply a new font and font size. This might require some readjustment of the above settings if the font changes any dimensions.

Optional: You can
select the row or just certain cells and apply a different Numeric (or other) Format.
  • Next, set up the border style to use in this model table (you'll adjust the last table in the stack later).
These are the lines around the cells. Omit (with an "X") the cell line on the bottom of all cells. On the cell tab, click on the "Bottom" button and then click the "X" icon. (Click OK.) This prevents the immediately adjacent table lines in the table stack from becoming darker than the other lines.
  • It might be a good idea at this point to copy the entire table into a new document and test the formatting for the typical text or other items you might use in any given row of the final table form. 

    You can, however, just proceed to the next step. Later you can always quickly create a single iteration of your model table in a (preferably empty) document using the QuickWord method (see next step). You can then tweak it if needed and then use it to re-create the same QuickWord abbreviation (delete the old one first).

Step 2. Create a QuickWord (N.B.: not QuickCorrect) from the model table that can be quickly reused on the page to create a stack of tables that will simulate a single table form. To create the QuickWord:

Select the table. When you have the model table set up as you wish, just open and use Reveal Codes to guide you in selecting everything in the model table from the [TblDef] to the [TblOff] codes (be sure to include both codes in the selection).

Then use Tools, QuickWords to create an abbreviation (e.g., \t [i.e., backslash-t] or similar abbreviation) for the selection and click Add Entry to add it to your QuickWords. (The abbreviation is known as the "QuickWord".)

Important: Be sure to enable 
"Expand as text with Formatting" using the Option button, and also enable "Expand QuickWords when you type them" at the bottom of the dialog.

Step 3. Create the entire form and adjust any desired cell widths:

Step 3a. Back in the main document, type the QuickWord abbreviation (in our example, \t) plus a space or <Enter> on each line where you need a new "row". The single-row model table should appear when each abbreviation expands. (If not, see the QuickWords page. Also, you'll need to backspace after each abbreviation to remove the space or [HRt] code to "join" the tables. For a simple macro that can do this in one step without requiring a space or the <Enter> key, see Footnote 1.)

Step 3b. For the last table -- which is used as the last row in your form -- simply "paint" all the cells with your mouse to select them (or use the Select Row method above), then right-click on the selection and choose Borders/Fill. Set all the cells in that row to have the bottom border enabled. Since you had disabled bottom borders in previous tables, and they are now covered by the immediately adjacent top border on the next table, this step will finish the form so all borders are visible (with no gaps) and they will print.

Step 3c. Now all you need to do is drag the vertical cell borders left or right to reposition them, and/or join selected cells (right-click the selected cells and choose Join Cells) to create the required data areas.

Other tips for when the general form has been created

Any row can have its own specific fixed height by clicking in any cell in the row and choosing Format, Row, Row height.

Cells can be locked to prevent then from being accidentally changed. (You can use Tab and Shift+Tab to move over them.) See here.

Caveats and limitations

If such a multi-table form needs to do calculations referencing other rows, in a similar manner to a single table, you will need to adjust formulas to reference cells in other tables.

(You can give names to tables, cells, ranges of cells, etc. See WordPerfect's online help (F1). See also the example macro in Footnote 1, which can automatically name the tables in a sequential fashion.)

[Thanks to WordPerfect Universe member 'Gettrained' for the basic idea behind this tip.]

Footnote 1

Example 1

You can play a simple, small macro to insert the pre-existing QuickWord abbreviation at the cursor location and immediately expand it without needing to type a space or use the <Enter> key. You could then assign it to a toolbar, shortcut key, or menu (see here) for quicker access.

(a) Create the QuickWord as described above in Step 2 to create your model one-row table, then -

(b) create a one-line macro with this command in it (which assumes that your QuickWord abbreviation for the model table is \t as in the Step 2 example):

AbbreviationExpand (AbbreviationName: "\t"; Template: QuickWords!)

To copy this macro into your WordPerfect so that it creates a functioning macro, which you can then play in your document, see here.

Example 2

To add a little automation to the above macro so that it creates "x" instances of the model table (here, it will create 15 of them), one under the other, in one step:

    AbbreviationExpand (AbbreviationName: "\t"; Template: QuickWords!)

You will still need to add the bottom border to the last table row as described in Step 3 above.

Example 3

For a little more automation and with some added error-checking:

The code below will give a NAME with a unique numerical suffix (1..n) to each table. Otherwise, by default they are all named TABLE A when the QuickWord expands (they are all clones of the model).

Tip: You can click in a table and choose Table, Names to see the current name. See below for a macro to display the table name, cell name, and cell address in any table.

Why do it? You can use table names to reference cells in the same (or any other) table in the document, for purposes of calculation. For example: TEST9.B3 would refer (here) to the table TEST9, cell B3.

Note that you need to adjust the first 3 variables (vQuickWordsAbbrev, vTableName, and vTotalNumber) before saving the macro and using it. As it stands now, if you play the macro it will produce 10 sequentially named tables (TEST1..TEST10) using the QuickWord you previous set up (\t in these examples) to produce your model one-row table.

// Store the QuickWord abbreviation to use:
// Store the name that the macro should give to each table:
// Store the total number of tables to create:
// Check if already in a table; if so, exit now:
    "This macro must be not be played inside an existing table.")

vTableNumber:=0  // (initialize a variable)
    AbbreviationExpand (AbbreviationName: vQuickWordAbbrev; Template: QuickWords!)
    TableNameAdd (RefType:Table!; Name:vNewTableName)
    vTableName:=vTableName-vTableNumber  // (re-set variable)
// Exit here:
    "Error - Cannot rename this table";
    "It appears that a table named -"+NToC(0F90Ah)+NToC(0F90Ah)+
    "- is already used in this document."+NToC(0F90Ah)+NToC(0F90Ah)+
    "This macro will use the WordPerfect default name TABLE (x) instead.")

You will still need to add the bottom border to the last table row as described in Step 3 above.

Example 4

If you want to see the table name and cell address the cursor is in, this macro will display it in a message box dialog:

    Messagebox(;"Cell information";
        "Table name: "+ x +NToC(0F90Ah)+
        "Cell name: "+ y +NToC(0F90Ah)+
        "Cell address: "+ x +"."+ y)
        "You must have the cursor inside a table to determine a cell's information.")