我在 Word 文档(启用宏或 .docm)中有一个现有的 tabale,我正在尝试向表中添加行。但我遇到运行时错误。
Private Sub Method1()
Dim tbl As Table
Dim rowtbl as Row
Set tbl = ActiveDocument.Tables(2)
Set rowtbl = tbl.Rows.Add(BeforeRow:=tbl.Rows(1)) ---> At this line we are getting runtime error
Set coltbl = tbl.Columns.Add(BeforeColumn:=tbl.Columns(1)) ---> At this line we are getting runtime error
End Sub
我已按照以下步骤解决了该错误。
我已遵循 MSDN 中的以下参考。 https://learn.microsoft.com/en-us/office/vba/api/word.columns https://learn.microsoft.com/en-us/office/vba/api/word.rows