InsertCells Method

Applies To

Selection object.

Description

Adds cells to an existing table. The number of cells inserted is equal to the number of cells in the selection.

Note You can also insert cells by using the Add method of the Cells object.

Syntax

expression.InsertCells(ShiftCells)

expression   An expression that returns a Selection object.

ShiftCells   Optional Variant. Can be one of the following WdInsertCells constants.

Constant

Description

wdInsertCellsEntireColumn

Inserts an entire column to the left of the column that contains the selection.

wdInsertCellsEntireRow

Inserts an entire row above the row that contains the selection.

wdInsertCellsShiftDown

Inserts new cells above the selected cells.

wdInsertCellsShiftRight

Insert new cells to the left of the selected cells.


See Also

Add method (Cells, Rows, and Columns collections), InsertColumns method, InsertRows method.

Example

This example inserts new cells to the left of the selected cells, and then it surrounds the selected cells with a red, single-line border.

If Selection.Cells.Count >= 1 Then
    Selection.InsertCells ShiftCells:=wdInsertCellsShiftRight
    For Each aBorder In Selection.Borders
        aBorder.LineStyle = wdLineStyleSingle
        aBorder.ColorIndex = wdRed
    Next aBorder
End If