Word VBA 寻找所在表格的序列号

6lilu9 6lilu9 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
Selection.RowIndex 可以得出当前选中的单元格在所在表格中的行
Selection.ColumnIndex 可以得出当前选中的单元格在所在表格中的列

但问题是当前的表格怎么获取呢?比如 Selection.TablesIndex之类的属性。

以下代码中的获取表名有问题,请高手给予正确的代码。
Sub 宏1()
Dim StrAddr As String
' This macro displays the address of a table's selected cell range
' and the table’s last cell address on Word's Status Bar
With Selection
If .Information(wdWithInTable) = True Then
StrAddr = "The selected "

If .Cells.Count = 1 Then
StrAddr = "T" & Selection.Tables(1).Range.Start & "R" & .Cells(1).RowIndex & "C" & .Cells(1).ColumnIndex
Else
StrAddr = "No Table Or More Tables "
End If
End If
End With

Call CopyToClipbox(StrAddr)

MsgBox StrAddr


End Sub
...全文
评论 5
收藏 已收藏
分享
返回顶部
6lilu9
VBA 2,506 成员 10,830 内容