Selecting the current cell

L

Larry Sulky

In Word VBA, what's a clean way to select the entirety of the current
cell (where the cursor has been clicked)?
 
D

Doug Robbins - Word MVP

Dim myrange as Range
Set myrange = Selection.Cells(1).Range
myrange.End = myrange.End - 1
'myrange will then contain just the text in the cell without the end of cell
marker.
'For most purposes, selecting the text is not necessary and it is better to
use the Range object.
'However, if you do want to select the text use
myrange.Select

Or, if you want to select the text, use

Selection.Cells(1).Range.Select
Selection.MoveEnd wdCharacter, -1



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
L

Larry Sulky

Perfect, Doug. I need to make use of both approaches from time to time
(using range versus select). Thanks!
--larry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top