Chapter 16. The Table Object

In this chapter:

  • Formatting-Related Properties and Methods

  • The Cell Method

  • The Columns and Rows Properties

  • The ConvertToText MethodD

  • Sorting Methods

  • The Split Method

  • Example: Creating Tables from Word Lists

  • Example: Closing Up a Table

A Table object represents a Word table. The Tables collection contains all of the tables in a range, selection, or document and is returned by the Tables property of the Range, Selection, or Document object. The properties and methods of a Table object are:

Application

Creator

Sort

AutoFormat

Delete

SortAscending

AutoFormatType

Parent

SortDescending

Borders

Range

Split

Cell

Rows

Uniform

Columns

Select

UpdateAutoFormat

ConvertToText

Shading

 

To add a new table to a document, use the Add method of the Tables collection. The syntax is:

TablesObject.Add(Range, NumRows, NumColumns)

where Range is a range that is replaced by the new table. (You can collapse the range to an insertion point using the Collapse method discussed in Chapter 13, The Section and HeaderFooter Objects, to avoid replacing any text.) The parameters NumRows and NumColumns specify the number of rows and columns in the table.

Let us take a look at some of the properties and methods of the Table object.

Formatting-Related Properties and Methods

The AutoFormat method applies a predefined formatting to a table. The parameters of this method correspond to the options in the Table AutoFormat dialog box (from the Table menu), shown in Figure 16-1 ...

Get Writing Word Macros, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.