Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Find and Replace Macro
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 |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Find and Replace Macro
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 -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. 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 |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Find and Replace Macro
Thanks very much for the macro. It is still not doing exactly what I want
though. It replaces the text but not other characters like periods, commas etc. It also leaves the strikethroughs visible (while at the same time turning the text to hidden and adding another strikethrough that is hidden, I think). Any more help you can provide would greatly be appreciated. I know I don't need the macro but I have to perform this task on many different documents and would prefer to not have to go throught the find and replace process for each one. Unless you know of an easier way to do it? I am still a novice with Word. David Ayers "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 -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. 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 |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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 |
#6
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Find and Replace Macro
Thanks again,
I had to tweak it a little this is what I have and it works! 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.Hidden = True End With .Execute Replace:=wdReplaceAll End With End Sub One more question though, is there a way to make it hide tables that have all cells struckthrough? This is not a deal breaker but just a convenience. Thanks again, David "Greg Maxey" wrote: 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 |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can I create a macro to find and replace text attributes? | Microsoft Word Help | |||
Find and Replace feature when recording a Macro | Microsoft Word Help | |||
Mega macro with find and replace (HELP!) | Microsoft Word Help | |||
Problem with function "Find and Replace" in Word. | Microsoft Word Help | |||
Find and Replace anomaly | Microsoft Word Help |