RE: highlight text in Microsoft Word

  • From: Dean Martineau <dean92@xxxxxxxxxxxxx>
  • To: jfw@xxxxxxxxxxxxx
  • Date: Mon, 07 Jun 2004 10:08:20 -0700

In fact, with the implementation of a couple simple macros (9instructions 
below,) anybody with any version of Word can have the ability to hit a key 
to seta mark and then hit another key to select between the marked position 
and the current position.  These macros were created by Ann Lord for me and 
anybody else who wants them.  You use the Word macro recorder.  There are 
three macros because apparently you have to run one if you are selecting in 
a forward direction and one if in a backward direction.  Hence, I never 
installed one of the macros since I always select from the mark 
downwards.  But with this, on my system, I can hit alt+m to set a mark and 
then alt+s to select all the text between the mark and my current 
position.  I chose the keystrokes.  Here are the instructions:


Use the macro recorder to record three macros.  Name them anything you 
want.  Tell the macro recorder that you want each macro saved in 
Normal.dot.  For each macro, as soon as you launch the macro recorder, turn 
it off without recording any actions.  You will be entering the code yourself.
Enter the following code for the first macro, the one that marks the 
original position:

     on error resume next

     ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="Start"

Enter the following code for the selection macro where the original 
position is after the second position:

     Dim rngRange As Range

     On Error Resume Next

     ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="End"

     Set rngRange = ActiveDocument.Range( _
         Start:=ActiveDocument.Bookmarks("End").Range.Start, _
         End:=ActiveDocument.Bookmarks("Start").Range.End)

     rngRange.Select

Enter the following code for the selection macro where the original 
position is before the second position:

     Dim rngRange As Range

     On Error Resume Next

     ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="End"

     Set rngRange = ActiveDocument.Range( _
         Start:=ActiveDocument.Bookmarks("Start").Range.Start, _
         End:=ActiveDocument.Bookmarks("End").Range.End)

     rngRange.Select

Activating the first macro will mark your current position.  Then when you 
move to another position and activate one of the other two macros, 
everything will be selected between the two positions.  If you accidentally 
activate the wrong one of the selection macros, nothing will happen, as 
error handling is in place.

--
To post a message to the list, send it to jfw@xxxxxxxxxxxxx
To unsubscribe from this mailing list, send a message to 
jfw-request@xxxxxxxxxxxxx with the word unsubscribe in the subject line.
Archives located at: //www.freelists.org/archives/jfw

If you have any concerns about the list, post received from the list, or the 
way the list is being run, do not post them to the list. Rather contact the 
list owner at jfw-admins@xxxxxxxxxxxxxx

Other related posts: