找到包含内容控件的表格单元格 [英] Locate table cell containing Content Control
本文介绍了找到包含内容控件的表格单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目标
我在 Word 中有一个包含 2 列的表格.第一个有一个下拉内容控制.
I have a table in Word with 2 columns. The first has a drop down Content Control.
我想用文本填充第二列,其值取决于所选的选项.
I would like to populate the second column with text, the value of which depends on the option selected.
问题
是否可以获取包含单击内容控件的单元格引用?我打算用它来定位包含内容的下一列.我在想这样的事情:
Is it possible to get the cell reference that contains the clicked content control? I plan to use that to target the next column with the content. I'm thinking of something like this:
Dim oCell As Cell
oCel = 'some way to get cell reference containing the ContentControl here
Dim curCellRow, curCellCol, targetCellRow, targetCellCol As Integer
curCellRow = oCell.Row
curCellCol = oCell.Column
targetCellRow = curCellRow
targetCellCol = curCellCol + 1
Dim NewCellContents As String
NewCellContents = "Sample Content for this cell"
ActiveDocument.Tables(1).Cell(targetCellRow, targetCellCol).Range.Text = NewCellContents
推荐答案
我已经解决了 - 我是这样解决的:
I worked it out - here's how I did it:
Dim RowNum As Long, ColNum As Long
If Selection.Information(wdWithInTable) Then
RowNum = Selection.Cells(1).RowIndex
ColNum = Selection.Cells(1).ColumnIndex
MsgBox "Row = " & RowNum & vbCr & _
"Column = " & ColNum
Else
MsgBox "Not in table"
End If
这篇关于找到包含内容控件的表格单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文