向原有表格添加单元格。插入的单元格数量等于选定内容中包含的单元格数量。
注意 用 Cells 对象的 Add 方法也可插入单元格。
expression.InsertCells(ShiftCells)
expression 必需。该表达式返回一个 Selection 对象。
ShiftCells 可选。 WdInsertCells。
可以是下列 WdInsertCells 常量之一。
常量 | 说明 |
---|---|
wdInsertCellsEntireColumn | 在所选内容的左侧插入整列。 |
wdInsertCellsEntireRow | 在所选内容的上方插入整行。 |
wdInsertCellsShiftDown | 在所选单元格的上方插入新单元格。 |
wdInsertCellsShiftRight | 在所选单元格的左侧插入新单元格。 |
本示例在所选单元格的左侧插入新单元格,然后为选定的单元格添加红色的单线边框。
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