The Sentences Object

     

The Sentences Object

The next rung on Word's text object ladder is the Sentences object. This is a collection of all the sentences in whatever object you specify, be it a Document , Range , or Selection .

As with Words , you refer to specific members of the Sentences collection using an index number, and the resulting object is a Range . For example, the following statement stores the active document's first sentence in the firstSentence variable:

 firstSentence = ActiveDocument.Sentences(1) 

Again, the Count property can be used to return the total number of sentences in an object. In the following procedure fragment, the Count property is used to determine the last sentence in a document:

 With Documents("Remarks.doc")      totalSentences = .Sentences.Count      lastSentence = .Sentences(.totalSentences) End With 


Absolute Beginner's Guide to VBA
Absolute Beginners Guide to VBA
ISBN: 0789730766
EAN: 2147483647
Year: 2003
Pages: 146

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net