Creating a Word Document 'Template' with auto-fill


I need to turn an existing Word document into a quick fill template. For example if my company has a proposal written for another company in MS Word format I want to turn that into a fillable 'template' so that the next time I just have to fill in the company's name, date, project title, etc.etc. and it will automatically auto populate the documents.

It's just like search and replace.

But I want it to have a wizard like interface if possible.

Any suggestions? I would appreciate a sample document too.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The simplest way would be to use form fields and forms protection. That you the user would not be able to edit the 'fixed' text, but have spaces to fill in the variable text.

Show the Forms toolbar.

Replace the variable text with text form fields - 'ab|' button. If you right-click on the inserted field, and choose 'Properties' from the pop-up, you can set the default text and formatting.

There are also checkbox and dropdown fileds that can be used.

To test the form, lock and unlock it using the padlock icon.

After the design is complete, if you protect the document via Tools/Protect document you will be able to set a password for unlocking the document. You can then save the document as a template.

It is possible to write a wizard in VBA, with a series of Userforms to gather data and to load the data onto the document. There are various techniques available to help locate the receiving position on the document - bookmarks, Ref fields and table cells are three. Actually, the easiest is to use form fields.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
happyguy82Author Commented:
Hi GrahamSkan,

Your answer is quite comprehensive for now and I thank you for it. Allow me a few days to try this out and in the meantime if you could furnish me with a sample document with the locked fields(also give me the password so I can unlock) it would be of great help.

Your proposal to create the wizards in VBA sounds great unfortunately I really don't know how to start this off. Could you please assist me with this?

I would be happy in increase the number of points for this question once I resolve this issue to my company's expectiation.

Thanks so much.

Warm Regards.
We can't post documents on this forum: we can only try to tell you how to do it as I did in my first comment. If you are having specific difficulty, let us know.

What to tell you about creating a VBA wizard depends on what you know about VBA already. If you are new to VBA, I suggest that you stick to the document form.

Otherwise I would point out that the main advantage of a Wizard is that the data can be validated. Also it can be used to modify the otherwise protected data. It could, for instance, be used to extend tables or to insert optional text.

General advice is to use one VBA userform for each logical group of data. Add some command buttons captioned "<<Back" and "Next>>" and perhaps "Cancel", "Apply" and "Finish". It helps to keep a correlation between the UserForm control names and the field names on the document. Remember that if you want the user to be able to restart the wizard on a partially completed document, you will have to read the document data on to the user form.
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

happyguy82Author Commented:
Hi GrahamSkan,

Ok I tried your form method but I have a question. Assuming the text field 'User Name' appears 5 times in the document, I want it to be such that once I fill out one of the field it will auto populate the rest. How can this be done w/o using wizard? Is there a way to 'tie' the editable text fields together?

Form field names are actually bookmarks which, of course, must be unique (and a single word) , so you can't have several actually called 'User Name'.

You can, however, have 'Ref' fields in the places that you want any data to be repeated, but they would not then be editable separately.

While the form is unlocked, you can see (and set) the form field name by right-clicking on the field and choosing 'Properties' from the pop-up. Make a note of the name. It  is in the box labelled 'Bookmark:'. While you are there, also make sure that 'Calculate on exit:' is ticked. That causes the 'Ref', and any other fields to be updated immediately you tab out of the form field.

Select each place for the 'Ref' field and do Insert/Field. Choose Ref and make sure that the formfiled bookmark name is entered.

Protect (lock) the document before testing.
Note that if you wanted to be able to change the "User Name" texts later to make then different from the first, but still be filled automatically after a change to the first one, they would have to be FormFields and the text copied with a VBA macro that has be set to be the first field's exit macro.

Sub MyExitMacro
      ActiveDocument.FormFields("UserName2").Result = ActiveDocument.FormFields("UserName1").Result
      ActiveDocument.FormFields("UserName3").Result = ActiveDocument.FormFields("UserName1").Result
      ActiveDocument.FormFields("UserName4").Result = ActiveDocument.FormFields("UserName1").Result
End Sub
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.