Multiple find & replace 
Author Message
 Multiple find & replace

Can someone tell me what's wrong with this code?  It was working and I don't
have any idea of what I did to break it.

It will do the first find & replace but then stops without doing the rest.

With Selection.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .MatchWildcards = False
    .Forward = True
    .Wrap = wdFindContinue
    .Text = "SIC Lines of Business Ad Size Year Appeared"
    .Replacement.Text = "Lines of Business:"
    .Execute Replace:=wdReplaceAll
    .Text = "Credit Rating Code*:"
    .Replacement.Text = "Credit Rating Code:"
    .Execute Replace:=wdReplaceAll
    .Text = "Fax**:"
    .Replacement.Text = "Fax:"
    .Execute Replace:=wdReplaceAll
    .Text = "Map It!"
    .Replacement.Text = ""
    .Execute Replace:=wdReplaceAll
End With



Mon, 24 Nov 2003 00:24:04 GMT  
 Multiple find & replace
Kooter

Your code works perfectly for me.  

Could it be any of the omitted settings that is stuffing it up for you?

        .Format = True/False
        .MatchCase = True/False
        .MatchWholeWord = True/False
        .MatchSoundsLike = True/False
        .MatchAllWordForms = True/False

As I understand it, Find retains the most recently used settings for these items. If you don't explicitly set them, Word uses the setting last used.
I recently had some code misbehave because of this.  I had to reinstate a specific setting for Match Case.

Might be worth a try.  You may only need to state them once, for the first Find/Replace.

Drew

Can someone tell me what's wrong with this code?  It was working and I don't
have any idea of what I did to break it.

It will do the first find & replace but then stops without doing the rest.

With Selection.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .MatchWildcards = False
    .Forward = True
    .Wrap = wdFindContinue
    .Text = "SIC Lines of Business Ad Size Year Appeared"
    .Replacement.Text = "Lines of Business:"
    .Execute Replace:=wdReplaceAll
    .Text = "Credit Rating Code*:"
    .Replacement.Text = "Credit Rating Code:"
    .Execute Replace:=wdReplaceAll
    .Text = "Fax**:"
    .Replacement.Text = "Fax:"
    .Execute Replace:=wdReplaceAll
    .Text = "Map It!"
    .Replacement.Text = ""
    .Execute Replace:=wdReplaceAll
End With



Wed, 26 Nov 2003 11:56:52 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. 'Find and Replace' across multiple documents

2. Find & Replace Problem - ACC97

3. Find& replace one by one

4. Find & Replace using input box

5. FIND & REPLACE

6. Find&replace-code

7. find & Replace with wild cards and patterns

8. find/replace on headers&footers

9. Excel macro to find&replace in MSWord

10. Find&Replace Tab

11. Global Find & Replace

12. Find & replace question

 

 
Powered by phpBB® Forum Software