Automatic search/replace

F

Finnegan's Mom

Hello,

I'm unsure if I'm posting in the correct area--but I'm creating
template with generic placeholders for information--right now, thi
generic placeholder is in brackets, like this: [insert product nam
here]. These are throughout the template. When a user creates a ne
document based on that template, I'd like a dialog box to appear th
first time that person opens the new document, allowing the user t
type the product name, and then have all the [insert product nam
here]'s replaced with what the user typed.

Is this possible?

TIA for your help
 
D

Doug Robbins - Word MVP

If there is only one piece of information to be inserted, you can get away
with an InputBox.

In place of your [insert product name here], I would insert a { DOCVARIABLE
varProductName } field in each location and then use the following code in
an autonew() macro in the template:

With ActiveDocument
.Variables("varProductName").Value = InputBox("Enter Product Name")
.Range.Fields.Update
End With

If there are multiple pieces of information, you could just repeat the above
two lines of code modified for each piece, but it is better to use a
UserForm:

See the article "How to create a Userform" at:

http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

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