Extract first words from each paragraph

  • Thread starter Thread starter Roger Smith
  • Start date Start date
R

Roger Smith

I would like to extract the first 15 words from each paragraph in a
long document or the whole paragraph if less than 15 words. Can
someone please help me with a macro to do the job?
Thanks.
 
Hi Roger,

Something like this should do it:

Sub FirstFifteen()
Dim oPar, strExtract
For Each oPar In ActiveDocument.Paragraphs
If Len(oPar.Range.Text) > 14 Then
strExtract = strExtract & Left(oPar.Range.Text, 15) & VbCrLf
Else
strExtract = strExtract & oPar.Range.Text & VbCrLf
End If
Next oPar
MsgBox strExtract ' or insert you own output routine here
End Sub

Cheers
 
Back
Top