Link to home
Start Free TrialLog in
Avatar of FaheemAhmadGul
FaheemAhmadGulFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VBA: how to determine in which Table your Cursor is in a Word Document that has several tables

In a Word Document I have several tables. In my Macros I can chose to run some code on one or the other of these tables by referring to the index number of a table with a line like this
ActiveDocument.Tables(1)
or
ActiveDocoument.Tables(2)

I would like to determine in which Table my Cursor is by Running a Macro.
So basically if I run my Macro when my Cursor is in (any Cell of) the Second Table in my Word Document I would like to display a MessageBox showing “2” and if my Cursor is in (any Cell of) the Table 1 I would like to display a MessageBox showing “1” and likewise for any other tables in my Word Document.
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of FaheemAhmadGul

ASKER

Excellent!
Thank you.