InsertCells 方法 (Word)Selection.InsertCells method (Word)

向原有表添加单元格。Adds cells to an existing table.

语法Syntax

expressionexpression. InsertCells( _ShiftCells_ )

expression:必需。expression Required. 表示 Selection 对象的变量。A variable that represents a Selection object.

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
ShiftCellsShiftCells 可选Optional WdInsertCellsWdInsertCells 指定如何将单元格插入到表的现有列和行中。Specifies how to insert the cells into the existing columns and rows of the table.

备注Remarks

插入的单元格数量等于选定内容中单元格的数量。The number of cells inserted is equal to the number of cells in the selection. 您还可以通过使用cells对象的**Add** 方法插入单元格。You can also insert cells by using the Add method of the Cells object.

示例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

另请参阅See also

Selection 对象Selection Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.