Microsoft KB Archive/94231

{|
 * width="100%"|

WD: WordBasic Macros to Select Different Document Elements

 * }

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, 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 &quot;\line&quot; 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 &quot;\Para&quot; 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 &quot;\page&quot; 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 &quot;\section&quot; 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.