View Single Post
 
Old 03-05-2020, 05:10 AM
robrob robrob is offline Windows 10 Office 2016
Novice
 
Join Date: Mar 2020
Posts: 3
robrob is on a distinguished road
Default spliting paragraphs after n words

i have a document with many paragraphs. all formated like:



T: ...
P: ...
T: ...



fist i delete all paragraphs with T: at the beginning with a macro that delete text between two words:



------------------------------------

Sub DeleteTextBetweenTwoWords()
Dim strFirstWord As String
Dim strLastWord As String
Dim objDoc As Document
Dim objWord As Object

Set objDoc = ActiveDocument
strFirstWord = "T:"
strLastWord = "P:"

With Selection
.HomeKey Unit:=wdStory
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = strFirstWord & "*" & strLastWord
.Replacement.Text = strLastWord
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
End With

Set objDoc = Nothing
Set objWord = Nothing
End Sub
------------------------------------------


the result is that i only get the paragraphs with P: at the beginning.

how can i split now the remaining paragraphs after, for example, 50 words?
Reply With Quote