Charlie Mac was telling us:
Charlie Mac nous racontait que :
I need to count the number of words in a sentence and the number of
sentences in each paragraph in a document? Please help.
Try this tio get you going:
'_______________________________________
Dim SelectedSentenceRge As Range
Dim SelectedParaRge As Range
Dim WordCountLng As Long
Dim SentCountLng As Long
Set SelectedSentenceRge = Selection.Range.Sentences(1)
'-1 because Word counts the final punctuation as a word.
WordCountLng = SelectedSentenceRge.Words.Count - 1
MsgBox WordCountLng
'or, in one line if you do not need the sentence range
'or word count elsewhere:
MsgBox Selection.Range.Sentences(1).Words.Count - 1
Set SelectedParaRge = Selection.Range.Paragraphs(1).Range
SentCountLng = SelectedParaRge.Sentences.Count
MsgBox SentCountLng
'or, in one line if you do not need the paragraph range
'or sentence count elsewhere:
MsgBox Selection.Range.Paragraphs(1).Range.Sentences.Count
'_______________________________________
For the total number of sentences per paragraph in the document, you need a
loop and a array.
o.caTHISTOO
Word MVP site:
http://www.word.mvps.org