The Split Method

The Split method applies to (among others) the Cell object, the Cells collection object, and the Table object. For a Cell object, the syntax is:

CellObject.Split(NumRows, NumColumns)

This will split the cell into multiple cells. For a Cells collection, the syntax is:

CellsObject.Split(NumRows, NumColumns, MergeBeforeSplit)

In this case, the method splits a range of cells. Finally, for the Table object, the syntax is:

TableObject.Split(BeforeRow)

In this case, the method inserts an empty paragraph immediately above the specified row in the table, thus splitting the table in two. The Split method returns a Table object that denotes the lower table. For example, assuming that the insertion point lies within the list of column object members earlier in this chapter, the code:

	Dim tbl As Table
	Dim tbl2 As Table
	Selection.Expand wdTable    ' Select table
	Set tbl = Selection.Tables(1)
	Set tbl2 = tbl.Split(3)

turns that table into two tables, as shown in Figure 16-2.

A table split into two parts

Figure 16-2. A table split into two parts

The various parameters of the Split method are:

NumColumns

The number of columns that the cell or group of cells is to be split into.

NumRows

The number of rows that the cell or group of cells is to be split into.

MergeBeforeSplit

Set to True to merge the cells with one another before splitting them.

BeforeRow

The row at which the table is split. This row becomes part of the lower ...

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.