WD: WordBasic Macros to Select Different Document Elements

ID: Q94231


The information in this article applies to:
  • Microsoft Word for Windows, versions 1.0, 1.1, 1.1a, 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1


SUMMARY

You can use the Microsoft WordBasic macros and commands detailed below be to select the following document elements:


   Word, Line, Sentence, Paragraph, Page, Section, Document 


MORE INFORMATION

The following macros apply to Word versions 7.x, 6.x and 2.x unless noted otherwise.

Word 6.x, 7.x Command

SelectCurWord

Word 2.x Select Word Macro

The following WordBasic macro selects the current word where the insertion point is located. The insertion point must be within a word and not positioned just before the word.

   Sub MAIN
      SelType 1
      WordLeft
      WordRight 1, 1
   End Sub 

Select Line Macro

The following WordBasic macro selects the current line where the insertion point is located.

   Sub MAIN
      SelType 1
      EditGoTo "\line"
   End Sub 

Word 6.x, 7.x Command

SelectCurSentence

Word 2.0 Select Sentence Macro

The following WordBasic macro selects the current sentence where the insertion point is located. The insertion point must be within the sentence and not positioned just before the sentence.

   Sub MAIN
      SelType 1
      SentLeft
      SentRight 1, 1
   End Sub 

Select Paragraph Macro

The following WordBasic macro can be used to select the paragraph of text where the insertion point is located.

   Sub MAIN
      SelType 1
      EditGoto "\Para"
   End Sub 

Select Page Macro

The following WordBasic macro can be used to select the current page in your document.

   Sub MAIN
      SelType 1
      EditGoTo "\page"
   End Sub 

Select Section Macro

The following WordBasic macro can be used to select the current section in your document.

   Sub MAIN
      SelType 1
      EditGoTo "\section"
   End Sub 

Select Document Macro

The following WordBasic command can be used to select all of the document text.
EditSelectAll
The SelType 1 command is used in the above macros to cancel an existing selection.


REFERENCES

"Using WordBasic," by WexTech Systems and Microsoft, page 184 and 279.

Additional query words: winword2 winword word95 word7 paragraph word line document macword section word6 sentence

Keywords : kbmacro wordnt kbmacroexample winword ntword macword word7
Version : MACINTOSH:6.0,6.0.1; WINDOWS:1.0,1.1,1.1a,2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a
Platform : MACINTOSH WINDOWS
Issue type : kbhowto


Last Reviewed: October 13, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.