Need code for prompt and find/replace macro - help!

M

MDon

Hello - total newbie to this, want to start doing more...

I'm trying to set up a macro attached to a document that, after using a
hotkey combination, prompts them for replacement text (for example, ABC
Company replaced with XYZ Corporation).

Basically, an automated way to engage the find/replace feature with a prompt
for replacement text.

I only understand the very basics of the code I've tried to create using the
Record feature, so I need some very basic instructions for my confused brain.

Can you tell me what I need? Many thanks!!

-Mike
 
G

Greg Maxey

Do you mean the user selects some text e.g., ABC company and you want to
initiate a macro that will prompt them to enter the replacement text?

Sub Scratchmacro()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = Selection.Text
.Wrap = wdFindAsk
.Replacement.Text = InputBox("Type replacment text here: ", "Replacement
Text")
.Execute Replace:=wdReplaceAll
End With
End Sub
 
G

Graham Mayor

How does this differ from pressing CTRL+H?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
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