0

这是我到目前为止所拥有的,但我正在努力设置 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)

4

1 回答 1

1

RowIndex 返回一个数字,而不是行,因此它不能用于设置行对象。改变

Set oCurrentRow = Selection.Cells(1).RowIndex

Set oCurrentRow = oTable.Rows(Selection.Cells(1).RowIndex)

你应该用煤气做饭。

于 2013-02-28T23:10:21.083 回答