Rows. Add 方法(Word)Rows.Add method (Word)

返回一个row对象,该对象代表添加到表中的行。Returns a Row object that represents a row added to a table.


表达式Add_BeforeRow_expression.Add ( _BeforeRow_ )

expression 是必需的。expression Required. 一个代表**Rows** 对象的变量。A variable that represents a Rows object.


名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
BeforeRowBeforeRow 可选Optional VariantVariant 代表将显示在新行正下方的行的 Row 对象。A Row object that represents the row that will appear immediately below the new row.

返回值Return value



本示例在选定内容的第一行之前插入一个新行。This example inserts a new row before the first row in the selection.

Sub AddARow() 
 If Selection.Information(wdWithInTable) = True Then 
 Selection.Rows.Add BeforeRow:=Selection.Rows(1) 
 End If 
End Sub

本示例在第一张表中添加一行,然后将文本 Cell 插入该行。This example adds a row to the first table and then inserts the text Cell into this row.

Sub CountCells() 
 Dim tblNew As Table 
 Dim rowNew As Row 
 Dim celTable As Cell 
 Dim intCount As Integer 
 intCount = 1 
 Set tblNew = ActiveDocument.Tables(1) 
 Set rowNew = tblNew.Rows.Add(BeforeRow:=tblNew.Rows(1)) 
 For Each celTable In rowNew.Cells 
 celTable.Range.InsertAfter Text:="Cell " & intCount 
 intCount = intCount + 1 
 Next celTable 
End Sub

另请参阅See also

行集合对象Rows Collection 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.