Word 2016-VBA-如何在表格中的选定行下方插入行? [英] Word 2016- VBA- How To Insert Row Below Selected Row In A Table?
本文介绍了Word 2016-VBA-如何在表格中的选定行下方插入行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试了Set oNewRow = Selection.InsertRowsBelow
,但生成了一个编译错误&预期函数或变量";。
Dim oTable As Table
Dim ocell As Cell
Dim oCC As ContentControl
Dim oNewRow As Row
Set oTable = ActiveDocument.Tables(1)
Set oNewRow = Selection.Rows.Add
Set ocell = oNewRow.Cells(1)
Set oCC = Selection.ContentControls.Add(wdContentControlRichText, ocell.Range)
With oCC
.DefaultTextStyle = "Style1"
.Tag = "Test1"
.Setplaceholdertext , , "test1"
If oCC.ShowingPlaceholderText Then
With ActiveDocument.Styles("Placeholder Text").Font
.Name = "Arial"
.Size = 8
.ColorIndex = wdRed
.Italic = True
End With
End If
End With
lbl_Exit:
Exit Sub
推荐答案
这很简单!我想知道你们在这方面投入了多少精力:
Selection.InsertRowsBelow
如果您想要复制一行--这是您的内容控件代码所建议的--请参阅以下任一项:
https://www.msofficeforums.com/word-vba/27809-code-add-new-row-table.html#post87989
https://www.msofficeforums.com/word-vba/13955-macro-add-row-table-word-form.html#post38461
这篇关于Word 2016-VBA-如何在表格中的选定行下方插入行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文