#1   Report Post  
Posted to microsoft.public.word.docmanagement
David Ayers
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
David Ayers
 
Posts: n/a
Default 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   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





  #6   Report Post  
Posted to microsoft.public.word.docmanagement
David Ayers
 
Posts: n/a
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I create a macro to find and replace text attributes? pubgal23 Microsoft Word Help 3 September 8th 05 06:09 AM
Find and Replace feature when recording a Macro WCRicster Microsoft Word Help 1 August 18th 05 07:23 PM
Mega macro with find and replace (HELP!) DKM Microsoft Word Help 1 May 10th 05 06:15 PM
Problem with function "Find and Replace" in Word. Pat Microsoft Word Help 3 March 16th 05 01:04 PM
Find and Replace anomaly BruceM Microsoft Word Help 7 January 18th 05 05:47 PM


All times are GMT +1. The time now is 09:59 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"