Macro for Finding Highlighted Text

E

e125

Version of Word 2003: I would like to record a macro for my finding
highlighted text in my documents. However, when I record the macros using the
"record a New Macro" feature in Tools, the recording button goes blank
indicating that the macro is no longer recording. Is there a way to work
around this glitch? Also, what is the VBA code for calling up the find and
replace dialog box?

Thanks in advance.
 
G

Graham Mayor

The macro recorder does not always work as you might hope. Some things you
have to code manually.
It is simple enough to find text that is highlighted - what do you want to
do with the highlighted text once you have found it?
The code to call the replace dialog is

Dialogs(wdDialogEditReplace).Show


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
E

e125

Thank you for the response. Upon finding the text, I need to 1) leave the
word / symbol selected; 2) close the dialog box; 3) analyze the highlighted
word or symbol it has found, then manually remove the highlighted word or
symbol. Steps 1 & 2 can be placed in a macro.

Thank you for your help.
 
G

Graham Mayor

The following macro will find the next highlighted item from the cursor
position

With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Highlight = True
.Wrap = wdFindContinue
.Execute
End With

Attach to a toolbar button or keyboard shortcut
http://www.gmayor.com/installing_macro.htm
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top