M
Matt Reed
I am trying to delete text in each of several paragraphs, starting at the
end of the Bolded text and deleting all text until the first tab.
This works find as long as each paragraph has both Bolded text and a tab. My
problem comes in when one of those items is not present in the same
paragraph. Then I end up deleting text in parts of more then one paragraph.
Sample - using CAPITAL letters for bolded text, the word 'tab' follows an
actual tab.
START of line and then it continues until tab, then more stuff and
end of paragraph.
I am trying to delete everything after the word START and before the tab.
Any help would be appreciated.
Matt
PS I'm using WordXP and my current code is bellow.
Sub CleanPara()
Dim objPar As Paragraph
For Each objPar In ActiveDocument.Paragraphs
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Font.Bold = True
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Collapse Direction:=wdCollapseEnd
Selection.Extend
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^t"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Next objPar
End Sub
end of the Bolded text and deleting all text until the first tab.
This works find as long as each paragraph has both Bolded text and a tab. My
problem comes in when one of those items is not present in the same
paragraph. Then I end up deleting text in parts of more then one paragraph.
Sample - using CAPITAL letters for bolded text, the word 'tab' follows an
actual tab.
START of line and then it continues until tab, then more stuff and
end of paragraph.
I am trying to delete everything after the word START and before the tab.
Any help would be appreciated.
Matt
PS I'm using WordXP and my current code is bellow.
Sub CleanPara()
Dim objPar As Paragraph
For Each objPar In ActiveDocument.Paragraphs
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Font.Bold = True
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Collapse Direction:=wdCollapseEnd
Selection.Extend
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^t"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Next objPar
End Sub