我在word文档上面加了3个表
怎么知道当前鼠标点中的表的索引号,选中的到底是tables(1)到底是tables(2)还是tables(3),书签有bookid,看selection.bookid就知道了,但是tables好像没有这个东西嘛,怎么办啊
在线等待.......
怎么知道当前鼠标点中的表的索引号,选中的到底是tables(1)到底是tables(2)还是tables(3),书签有bookid,看selection.bookid就知道了,但是tables好像没有这个东西嘛,怎么办啊
在线等待.......
你可以录制宏,看看宏代码就知道了'打开Word,在菜单的"工具"->"宏"->"录制新宏",然后开始对Word操作,操作完了停止录制宏,在"宏"->"Visual Basic编辑器"->"模块"里的模块就有你录制的过程的代码,把需要的代码稍微修改就可以直接应用到vb里
Dim i As Integer
For i = 1 To ActiveDocument.Tables.Count
If Selection.InRange(ActiveDocument.Tables(i).Range) Then Exit For
Next
MsgBox IIf(i > ActiveDocument.Tables.Count, "No tables are selected!", "tables(" & i & ") is selected!")
End Sub
你没有找到吗?
Dim i As Integer
For i = 1 To ActiveDocument.Tables.Count
If Selection.InRange(ActiveDocument.Tables(i).Range) Then Exit For
Next
MsgBox IIf(i > ActiveDocument.Tables.Count, "No tables are selected!", "tables(" & i & ") is selected!")
End Sub