You are currently offline, waiting for your internet to reconnect

WD2000: How to Select the Current Paragraph by Using Macro Code

This article was previously published under Q212529
SUMMARY
This article describes how to select the current paragraph (the one that contains the insertion point) by using Microsoft Visual Basic for Applications macro code.

NOTE: You can select a paragraph in Microsoft Word without the use of a macro when you triple-click with your mouse anywhere inside the paragraph.
MORE INFORMATION
Microsoft 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.
For more information about how to use the sample code in this article, clickthe article number below to view the article in the Microsoft Knowledge Base:
212536 OFF2000: How to Run Sample Code from Knowledge Base Articles
In Microsoft Word, you can use one of the following alternative methods to select the current paragraph, by using Visual Basic for Applications macro code.

Method 1: Use 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:
Sub SelectCurrentParagraph()   Selection.GoTo What:=wdGoToBookmark, Name:="\Para"End Sub				

Method 2: Use 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:
Sub SelectCurrentParagraph()   Selection.StartOf Unit:=wdParagraph   Selection.MoveEnd Unit:=wdParagraphEnd Sub				

Method 3: Use the Select Method

You can use the Select method of the Selection object to select the current paragraph, as in the following Visual Basic statement:

Sub SelectCurrentParagraph()   Selection.Paragraphs(1).Range.SelectEnd Sub				
REFERENCES
For additional information about how to move the insertion point within a paragraph, click the article number below to view the article in the Microsoft Knowledge Base:
212696 WD2000: Macros to Move to Beginning and End of Paragraph
For additional information about getting help with Visual Basic for Applications, click the article numbers below to view the articles in the Microsoft Knowledge Base:
212623 WD2000: Macro Programming Resources
226118 OFF2000: Programming Resources for Visual Basic for Applications
vb vba vbe cursor focus
Properties

Article ID: 212529 - Last Review: 10/11/2006 15:42:20 - Revision: 3.2

  • Microsoft Word 2000 Standard Edition
  • kbdtacode kbhowto KB212529
Feedback