Creating a Word Document 'Template' with auto-fill

Posted on 2006-04-13
Last Modified: 2008-02-01

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.

Question by:happyguy82
    LVL 76

    Accepted Solution

    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.

    Author Comment

    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.
    LVL 76

    Expert Comment

    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.

    Author Comment

    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?

    LVL 76

    Expert Comment

    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.
    LVL 76

    Expert Comment

    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

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
    Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
    This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
    This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now