在word 表格中可以插入行列。
如果要用vba給word表格插入行或者列,可以使用如下的代碼:
Sub exceloffice() '作者QQ:1722187970,微信:xycgenius,微信公眾號exceloffice Dim oDoc As Document Set oDoc = Word.ActiveDocument Dim oT As Table Dim oRow As Row Dim oColumn As Column With oDoc Set oT = .Tables(1) With oT '設置要在第幾行前面插入行,這里是第2行 Set oRow = .Rows(2) '在第2行前面插入行 .Rows.Add oRow Set oColumn = .Columns(3) '在第3列左邊插入一個空列 .Columns.Add oColumn End With End With End Sub
其中Rows.Add方法和Columns.Add后面必須帶具體的某行或某列對象。