Word 2016-如何在Table-VBA的所有单元格中插入带有内容控件的行?
Word 2016- How To Insert Row Below With Content Controls In All Cells of A Table- VBA?
我有一个 table 有 1 行和 5 列(单元格)。
以下代码成功地在下面插入一行,其中有 5 列,但只有一个内容控件插入到第一个单元格中。
Dim oTable As table
Dim oCell As Cell
Dim oNewRow As Row
Set oTable = ActiveDocument.Tables(1)
Set oNewRow = oTable.Rows.Add
Set oCell = oNewRow.Cells(1)
ActiveDocument.ContentControls.Add wdContentControlRichText, oCell.Range
lbl_Exit:
Exit Sub
如何将内容控件输入行中的所有 5 个单元格?
根据蒂姆·威廉姆斯的建议:
Dim oTable As table
Dim oCell As Cell
Dim oNewRow As Row
Set oTable = ActiveDocument.Tables(1)
Set oNewRow = oTable.Rows.Add
Set oCell = oNewRow.Cells(1)
ActiveDocument.ContentControls.Add wdContentControlRichText, oCell.Range
Set oCell = oNewRow.Cells(2)
ActiveDocument.ContentControls.Add wdContentControlRichText, oCell.Range
Set oCell = oNewRow.Cells(3)
ActiveDocument.ContentControls.Add wdContentControlRichText, oCell.Range
Set oCell = oNewRow.Cells(4)
ActiveDocument.ContentControls.Add wdContentControlRichText, oCell.Range
Set oCell = oNewRow.Cells(5)
ActiveDocument.ContentControls.Add wdContentControlRichText, oCell.Range
lbl_Exit:
Exit Sub
我有一个 table 有 1 行和 5 列(单元格)。
以下代码成功地在下面插入一行,其中有 5 列,但只有一个内容控件插入到第一个单元格中。
Dim oTable As table
Dim oCell As Cell
Dim oNewRow As Row
Set oTable = ActiveDocument.Tables(1)
Set oNewRow = oTable.Rows.Add
Set oCell = oNewRow.Cells(1)
ActiveDocument.ContentControls.Add wdContentControlRichText, oCell.Range
lbl_Exit:
Exit Sub
如何将内容控件输入行中的所有 5 个单元格?
根据蒂姆·威廉姆斯的建议:
Dim oTable As table
Dim oCell As Cell
Dim oNewRow As Row
Set oTable = ActiveDocument.Tables(1)
Set oNewRow = oTable.Rows.Add
Set oCell = oNewRow.Cells(1)
ActiveDocument.ContentControls.Add wdContentControlRichText, oCell.Range
Set oCell = oNewRow.Cells(2)
ActiveDocument.ContentControls.Add wdContentControlRichText, oCell.Range
Set oCell = oNewRow.Cells(3)
ActiveDocument.ContentControls.Add wdContentControlRichText, oCell.Range
Set oCell = oNewRow.Cells(4)
ActiveDocument.ContentControls.Add wdContentControlRichText, oCell.Range
Set oCell = oNewRow.Cells(5)
ActiveDocument.ContentControls.Add wdContentControlRichText, oCell.Range
lbl_Exit:
Exit Sub