Find/Replace MS Word Macro

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

ns81

Thread Starter
Joined
Jul 11, 2007
Messages
32
I have written a macro in MS Word that basically checks items off a list. It is based off of the seach and replace function, all it does is serach for a term and when it finds it changes it's color to blue and makes it strikethrough. I don't know if this is the most efficient way of doing it but this is the way I've come up with.

What I would like to add to it is the ability to have it tell me when the term is not found in the list, and possibly add it to the bottom of the list in a red color or something. Anyone know how I could do that?

Here is the macro code:


Sub CrossOff()

For x = 1 To 5 'Find and replace 5 times

SearchTerm = InputBox("Word to search")

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting

With Selection.Find
.Text = SearchTerm 'Word to search for
.Replacement.Text = SearchTerm 'Replace with same word, different

formatting
End With

'Selection.Find.Replacement.ClearFormatting

With Selection.Find.Replacement
.Text = SearchTerm
.Font.Color = wdColorBlue 'change the text to blue
.Font.StrikeThrough = True 'cross it out
End With

Selection.Find.Execute Replace:=wdReplaceAll

Next x

End Sub
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top