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

在所选内容的上方插入指定数量的新行。Inserts the specified number of new rows above the row that contains the selection. 如果选定内容不在表格中,则会导致出错。If the selection isn't in a table, an error occurs.

语法Syntax

expressionexpression. InsertRows( _NumRows_ )

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

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
NumRowsNumRows 可选Optional VariantVariant 需要添加的行数。The number of rows to be added.

备注Remarks

您还可以使用rows对象的**Add** 方法插入行。You can also insert rows by using the Add method of the Rows object.

示例Example

本示例在选定内容的上方插入两个新行,然后删除新行的边框。This example inserts two new rows above the row that contains the selection, and then it removes the borders from the new rows.

If Selection.Information(wdWithInTable) = True Then 
 Selection.InsertRows NumRows:=2 
 Selection.Borders.Enable =False 
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.