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

Article translations Article translations
Article ID: 212529 - View products that this article applies to.
This article was previously published under Q212529
Expand all | Collapse all

On This Page

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, click the 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:=wdParagraph

End 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.Select

End 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

Properties

Article ID: 212529 - Last Review: October 11, 2006 - Revision: 3.2
APPLIES TO
  • Microsoft Word 2000 Standard Edition
Keywords: 
kbdtacode kbhowto KB212529

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com