Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
dmpollock dmpollock is offline
external usenet poster
 
Posts: 2
Default Get current column/row index

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
  #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.


  #3   Report Post  
Posted to microsoft.public.word.tables
dmpollock dmpollock is offline
external usenet poster
 
Posts: 2
Default Get current column/row index

This was perfect.

Thanks much.

"Jay Freedman" wrote:

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.



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word index at current cursor location Ashish Sharma[_2_] Microsoft Word Help 3 May 27th 08 09:00 AM
How to get the current Table Index value in my VBA Macro? vrk1 Tables 4 February 28th 08 07:34 PM
how to jump from index to contents in document and back to index? cabo_cat New Users 1 December 21st 05 02:41 PM
Identical 2-level index tags yield different results in index. Hel Leslie in Montreal Microsoft Word Help 2 April 28th 05 07:12 PM
Concordance/Index File--Make Index Entries Case Insensitive erik_gregory Microsoft Word Help 1 February 11th 05 09:03 PM


All times are GMT +1. The time now is 03:11 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"