在word 表格中可以插入行列。
如果要用vba給word表格插入行或者列,可以使用如下的代碼:
Sub 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
'設(shè)置要在第幾行前面插入行,這里是第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后面必須帶具體的某行或某列對象。
相關(guān)教程:
?
【Office】利用VBA在Word模板文檔的末尾插入一個3行4列表格,并在單元格中插入指定內(nèi)容[
5]
http://28745.oa22.cn
【Excel】VBA復(fù)制指定單元格內(nèi)富文本內(nèi)容,并賦值給另外一個單元格,避免文字不同大小、粗細(xì)、顏色等格式丟失[
5]
http://28666.oa22.cn
【VBA】在Excel外部查找和替換Word模板文件中的自定義變量引用(本方法適用于微軟Office和金山WPS軟件)[
141]
http://28652.oa22.cn
【Office】vba如何替換Excel單元格文本中的換行為指定字符,實現(xiàn)導(dǎo)出到Word模板中變量時仍然保留換行符?[
245]
http://28733.oa22.cn
【Office】將Excel表格內(nèi)容導(dǎo)出到Word模板的指定表格中,并保留Word表格中的要求指定格式[
12]
http://28742.oa22.cn
【Office】Excel中如何清除單元格數(shù)據(jù)有效性驗證(下拉菜單)?[
39]
http://28737.oa22.cn
【Office】Word中VBA之Find.Execute方法參數(shù)說明[
205]
http://28735.oa22.cn
該文章在 2025/1/17 11:46:55 編輯過