Word.Tips.Net Welcome toWord.Tips.Net

Helpful Links

Tips.Net Home
WordTips Home

Ask a Word Question
Make a Comment

Tips.Net Store

WordTips FAQ
WordTips Premium

Learn Access Now
Free Printable Forms

Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips

Advertise on the
WordTips Site

Newest Tips

Setting Fraction Bar Overhang Spacing in the Equation Editor

Printing On Both Sides of the Paper

Turning Off AutoComplete for Dates

Ordering Search and Replace

Understanding Auto Line Spacing

Adding Comments to Your Document

Conditional Calculations in Word

 

Selecting Sentences with VBA

Summary: Need to select an entire sentence at once? You can do so by creating a short macro that does the task for you, or you can assign shortcut keys to some built-in Word commands that aren't normally accessible. (This tip works with Microsoft Word 97, Word 2000, Word 2002, and Word 2003.)

Word does not provide function keys for you to step through your document one sentence at a time. If you are used to a different word processor, you may consider such a capability rather important. The following macro, StepRightSentence, provides the capability to step through a document one sentence at a time toward the right. You can assign the macro either to a shortcut key or to a toolbar button.

Sub StepRightSentence()
   If Selection.Type <> wdNoSelection Then
      Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdMove
   End If
   Selection.Sentences(1).Next(Unit:=wdSentence, Count:=1).Select
End Sub

If you want to use Word to step through a document toward the left (beginning of the document), you can use the following macro, StepLeftSentence:

Sub StepLeftSentence()
   If Selection.Type <> wdNoSelection Then
      Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdMove
   End If
   Selection.Sentences(1).Previous(Unit:=wdSentence, Count:=1).Select
End Sub

Regardless of which of these macros you use, the result is that you step through your document, one sentence at a time. After running the macro, the next sentence--left or right--is selected. If you instead want to only jump to the beginning of the sentence, without selecting it, add the following line as the final line in the macro, just before the End Sub statement:

   Selection.Collapse Direction:=wdCollapseStart

If you prefer to not use macros, you can also move through sentences by customizing Word to take advantage of some "hidden" commands. Follow these steps:

  1. Choose the Customize option from the Tools menu. Word displays the Customize dialog box. (Click here to see a related figure.)
  2. Click on the Keyboard button. Word displays the Customize Keyboard dialog box. (Click here to see a related figure.)
  3. In the Categories list, choose All Commands.
  4. In the Commands list, choose SentLeft.
  5. Click in the Press New Shortcut Key box.
  6. Press Alt+Left Arrow.
  7. Click on Assign.
  8. Click on Close to dismiss the Customize Keyboard dialog box.
  9. Click on Close to close the Customize dialog box.

After performing this series of steps, you can step backwards through your document, one sentence at a time, simply by pressing Alt+Left Arrow. You can also repeat the steps and assign the following

Action Commands List Shortcut Key
Step right by sentences SentRight Alt+Right Arrow
Step left and select SentLeftExtend Shift+Alt+Left Arrow
Step right and select SentRightExtend Shift+Alt+Right Arrow

Most Word users will find these keyboard commands a welcome addition to the normal editing keys. You should know, however, that some of these suggested shortcut keys are already in use by Word. For instance, the Shift+Alt+Left Arrow combination is used to promote a heading level in an outline. However, if you can live without that use of the keys, then go for it. (Personally, I think this reassigned use makes much more sense.) If you would rather use a different key combination, you can do so by using any one you would like in step 6 above.

Tip #979 applies to Microsoft Word versions: 97 | 2000 | 2002 | 2003

Save Time! WordTips has been published weekly since early 1997. Past issues are available in convenient WordTips archives. Have your own enhanced archive of WordTips at your fingertips, available to use at any time!
 
Check out WordTips Archives today!