View Single Post
  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey
 
Posts: n/a
Default Find and Replace Macro

David,

Yes I see what you mean. This isn't tested extensively (like the last), but
try:

Sub ScrathcMacro()
Dim rngstory As Word.Range
Set rngstory = ActiveDocument.Range
With rngstory.Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWildcards = True
.MatchWholeWord = True
.Wrap = wdFindContinue
.Text = "*"
.Font.StrikeThrough = True
With .Replacement
.Text = "^&"
.Font.Bold = True
.Font.Hidden = True
End With
.Execute Replace:=wdReplaceAll
End With
End Sub


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

Greg Maxey wrote:
David,

You don't need a macro for this, but here is one that should work:
Sub ScrathcMacro()
Dim rngstory As Word.Range
Set rngstory = ActiveDocument.Range
With rngstory.Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWildcards = False
.MatchWholeWord = True
.Wrap = wdFindContinue
.Text = ""
.Font.StrikeThrough = True
With .Replacement
.Text = ""
.Font.Bold = True
.Font.Hidden = True
End With
.Execute Replace:=wdReplaceAll
End With
End Sub



David Ayers wrote:
I am trying to create a macro to find text that has been
struckthrough and replace it with text that is still struckthrough
but hidden.

When I use the macro recorder this is what I get (the find and
replace command works great but the macro does not do anything):

Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

From what I can tell I need to insert something in between the quotes
but am not sure what to insert. I am using Word 2002.

Thanks,
David