WD98: How to Select the Current Paragraph Using VBA Code (184189)
The information in this article applies to:
- Microsoft Word 98 Macintosh Edition
This article was previously published under Q184189 SUMMARY
This article describes how to select the current paragraph the cursor is in
using Microsoft Visual Basic for Applications code.
MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
In Word 98 Macintosh Edition, the WordBasic programming language was
replaced with Visual Basic for Applications. In WordBasic, you used the
following code to select the current paragraph:
EditGoTo "\para"
To select the current paragraph using Visual Basic for Applications code,
you can use one of the following alternative methods.
Method 1: Using the GoTo Method
You can use the GoTo method of the Selection object to select the current
paragraph, as in the following Visual Basic statement:
Selection.GoTo What:=wdGoToBookmark, Name:="\para"
Method 2: Using the StartOf and MoveEnd Methods
You can use the StartOf and MoveEnd methods of the Selection object to
select from the beginning to the end of the paragraph, as in the following
Visual Basic statements:
Selection.StartOf Unit:=wdParagraph
Selection.MoveEnd Unit:=wdParagraph
Method 3: Using the Select Method
If you know the number of the paragraph you want to select, you can use the
following statement:
Selection.Paragraphs(n).Range.Select
where n is the number of the paragraph you want to select. For example, the
following statement selects the third paragraph in the document:
Selection.Paragraphs(3).Range.Select
For additional information, please see the following article in the
Microsoft Knowledge Base:
181058 OFF98: How to Run Sample Code from Knowledge Base Articles
REFERENCES
For more information about getting help with Visual Basic for Applications,
please see the following article in the Microsoft Knowledge Base:
163435 VBA: Programming Resources for Visual Basic for Applications
Modification Type: | Major | Last Reviewed: | 6/17/2005 |
---|
Keywords: | kbdtacode kbhowto kbmacroexample KB184189 |
---|
|