If you had asked for that, I would have given it to you. It is simply
Dim asentence As Range
For Each asentence In ActiveDocument.Range.Sentences
If asentence.Words.Count > 40 Then
MsgBox asentence.Words(1)
End If
Next
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
"BHW"
news:29df7aa0-f53b-4dc0-b685-bc490dbb8582@c65g2000hsa.googlegroups.com...
> That's great (thank you). If you could show me the additional code for
> running this code over the entire document, I'd be all set. thanks
> again.
>
> Bruce
>
> PS Any suggestions for where to learn more about programming Word?
>
> On Mar 22, 6:19 pm, "Doug Robbins - Word MVP"
>
>> The following displays the first word of each sentence in the paragraph
>> in
>> which the selection is located if the sentence contains more than 40
>> words.
>> You can adapt it to do what you want.
>>
>> Dim asentence As Range
>> For Each asentence In Selection.Paragraphs(1).Range.Sentences
>> If asentence.Words.Count > 40 Then
>> MsgBox asentence.Words(1)
>> End If
>> Next
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "BHW"
>>
>> news:5004edde-616e-4e13-87c5-58b4c7535f54@x30g2000hsd.googlegroups.com...
>>
>> >I have a little macro that finds long sentences in my entire document
>> > and highlights the first word of each long sentence. Generally I will
>> > fix the offending sentence, but it still might be too long. I'd like a
>> > macro that checks each sentence in the paragraph containing the
>> > offending sentence and removes highlighting (if necessary). Here's
>> > what I have so far.
>>
>> > For the entire document:
>>
>> > Sub longsent()
>> > Dim item As Range
>>
>> > For Each item In ActiveDocument.Sentences
>>
>> > 'item.Select
>>
>> > If item.Words.Count > 40 Then
>> > item.Words.First.HighlightColorIndex = wdYellow
>> > 'MsgBox ("Num words = " & item.Words.Count)
>> > End If
>>
>> > Next item
>> > End Sub
>>
>> > this works for individual sentences, where I have the cursor inside of
>> > the sentence.
>>
>> > Sub testsent()
>> > Selection.Range.Sentences.First.Select
>> > Selection.Words.First.HighlightColorIndex = wdNoHighlight
>> > If Selection.Words.Count > 40 Then
>> > MsgBox ("still long " & Selection.Words.Count & " words")
>> > Selection.Words.First.HighlightColorIndex = wdYellow
>> > End If
>> > Selection.Range.Sentences.First.Select
>> > rem try to deselect sentence - doesn't work
>>
>> > End Sub
>>
>> > Thanks!
>