这是我到目前为止所拥有的 但我正在努力设置oCurrentRow
Sub InsertRow()
Dim EventDate As String
Dim oTable As Table
Dim oCell As Cell
Dim oCurrentRow As Row
Dim oNewRow As Row
If Not Selection.Information(wdWithInTable) Then
MsgBox "Can only run this within a table"
Exit Sub
End If
Set oTable = ActiveDocument.Tables(1)
Set oCurrentRow = Selection.Cells(1).RowIndex
oCurrentRow.Select
With Selection
.Collapse Direction:=wdCollapseStart
.InsertRowsAbove 1
End With
' go to inserted row and insert text
End Sub
我猜我曾经在上面插入一行 oCurrentRow将引用新插入的行 我想在单元格(1)中添加一些文本
答案 0 :(得分:0)
RowIndex返回一个数字,而不是一行,因此它不能用于设置行对象。变化
Set oCurrentRow = Selection.Cells(1).RowIndex
要
Set oCurrentRow = oTable.Rows(Selection.Cells(1).RowIndex)
你应该用煤气做饭。