View Single Post
  #2   Report Post  
Posted to microsoft.public.word.tables
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Get current column/row index

dmpollock wrote:
I am writing a macro to enter text into a table. How can I get the
current column and row number where the cursor is in the table?

thanks


Use the .Information property of the Selection object with the appropriate
constants:

Selection.Information(wdEndOfRangeColumnNumber)
Selection.Information(wdEndOfRangeRowNumber)

If the selection is extended and contains more than one cell, the numbers
returned refer to the location of the end of the selection. If you think
that might be the situation, and you want the location of the beginning of
the selection, you can do something like this:

Dim myRg As Range
Set myRg = Selection.Range
MyRg.Collapse Direction:=wdCollapseStart
MyRow = MyRg.Information(wdEndOfRangeRowNumber)

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.