If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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. |
Thread Tools | |
Display Modes | |
|
|