Re: Deriving the word (range) at cursor location

Tech-Archive recommends: Fix windows errors by optimizing your registry




"MAB" <MAB@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:4C691747-7A0B-434F-9895-C4E1E12D3EA8@xxxxxxxxxxxxxxxx
Thanks for the help Jonathan & Jay

I was able to expand the selection with the following
l1 = Sel.MoveStart(wdWord, -1)
l2 = Sel.MoveEnd(wdWord, 1)
If Right(Sel.Text, 1) = " " Then l2 = Sel.MoveEnd(wdCharacter, -1)
however I would perfer not to expand the selection. I'd rather calulate a
range instead (how?).

Also, It seems the user cannot change the background color of a word that I
programmatically set early. Do you have any idea why?

The Words collection is a collection of Range objects. Really, do please just *try* Jay's code. You *don't* need to expand the selection in order to get the whole word that contains the selection by means of Selection.Words(1).


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

.



Relevant Pages

  • Re: Nested Subtotal and Macro
    ... You are correct that the selection is not being expanded - ... naming a range that might expand to include the grand ... For now I have split the macro in two and am executing it ...
    (microsoft.public.excel.programming)
  • Re: Keyboard shortcut to select the word immediately around the cursor
    ... If you only pressed F8 once, you could use arrow keys to expand the selection one character at a time or you could use the 'period' key to expand to grab the entire sentence etc. ... You can expand or reduce the selection as often as you like prior to getting out of 'extended selection' mode by using the Esc key. ...
    (microsoft.public.word.docmanagement)
  • RE: Cannot expand the selection to entire spreadsheet when sorting
    ... The selection will not expand across a totally blank column or row. ... I am not clear on what you mean by "I checked the prior columns ... I am highlighting the column and clicking on Sort. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Excel Sorting Problem
    ... If you select the Rows using the Row headers starting at Row 4 you should not ... get the meesage asking to "Expand the selection". ...
    (microsoft.public.excel.worksheet.functions)