J
Julia
Hi - this macro should find "Invoice=" and then select from the previous page
break to the following page break and delete. It's deleting multiple pages.
Any ideas why? I really appreciate the help:
Sub BillAdd1()
'
With Selection
.WholeStory
.ExtendMode = False
.Collapse
End With
With Selection.Find
.Text = "invoice="
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
While .Execute
' Selection.Find.Execute
Selection.HomeKey unit:=wdLine
With Selection.Find
.Text = "^m"
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
'.Wrap = wdFindAsk
End With
Selection.Find.Execute
Selection.MoveRight unit:=wdCharacter, Count:=1
Selection.Extend
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^m"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
End With
Selection.Find.Execute
Selection.Delete unit:=wdCharacter, Count:=1
Selection.MoveDown unit:=wdLine
Wend
End With
End Sub
break to the following page break and delete. It's deleting multiple pages.
Any ideas why? I really appreciate the help:
Sub BillAdd1()
'
With Selection
.WholeStory
.ExtendMode = False
.Collapse
End With
With Selection.Find
.Text = "invoice="
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
While .Execute
' Selection.Find.Execute
Selection.HomeKey unit:=wdLine
With Selection.Find
.Text = "^m"
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
'.Wrap = wdFindAsk
End With
Selection.Find.Execute
Selection.MoveRight unit:=wdCharacter, Count:=1
Selection.Extend
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^m"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
End With
Selection.Find.Execute
Selection.Delete unit:=wdCharacter, Count:=1
Selection.MoveDown unit:=wdLine
Wend
End With
End Sub