Simple Active X question.

K

Kevin Ashton

I'm trying to create a document for my dad that would
allow him to type the customers name once into a textbox
at the top of the document.

How would I think insert that name automatically into
several places in the document? Is there any simple way
of doing this? Thanks for any advice. :)
 
D

Doug Robbins - Word MVP

Hi Kevin,

What you should create for him is a template and store that in the Templates
folder. He should use it by selecting New from the File menu and then
select that template as the basis for the document that he wants to create.

If it is just one item that he wants to enter in this way, the simplest
thing is to have an autonew macro in that template that calls and InputBox
in which he enters the data. The code in the autonew macro will then create
a Document Variable that will hold the data that was entered into the
InputBox and by means of { DOCVARIABLE } fields that you locate in the
document where you want the data to appear, the date will then appear in the
document.

The code for such a procedure would be

Dim Message, Title, Default
Message = "Enter the Company name." ' Set prompt.
Title = "Input Company Name" ' Set title.
Default = "" ' Set default.
' Display message, title, and default value.
ActiveDocument.Variables("CompanyName").Value = InputBox(Message, Title,
Default)
ActiveDocument.Fields.Update

If there is more than one piece of information, it is better to use a
userform which is a custom dialog to which you can add controls for each of
the pieces of information.

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

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

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a consulting basis.

Hope this helps
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