View Single Post
  #7   Report Post  
Posted to microsoft.public.word.newusers
Oggy Oggy is offline
external usenet poster
 
Posts: 6
Default select text, search, delete, in a macro, how?

That works really well. Thanks! I learned a lot about macros.

I built the macro call in a DOS batch file since I have to apply it to
over a hundred files every week. Do you know to automatically save the
file and close the macro so that the DOS loop can proceed to the next
file? Right now, when Word is launched with the macro, the file stays
open after the macro runs. I would like to automatically save the
file, and close it.


macropod said the following on 8/11/2009 6:36 PM:
Hi Oggy,

Try:
Sub CleanUp()
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "(\div id=""personalmain"")(*)(\\/div\?)"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
.Text = "(\div id=""productdetails"")(*)(\\/div\?)"
.Execute Replace:=wdReplaceAll
End With
End With
End Sub