How to make a Word document force me to fill in some fields when I open it?

2

I have a Word document that I use for quotations. Every time I make new one, I need to change some fields (company name, person addressed, etc.). I want the file to require me to fill in those fields in a pop-up window when I open it, so I don't miss any. Is this possible?

rodsarria

Posted 2016-02-03T19:12:43.433

Reputation: 23

"Prompting you to fill in the fields" is ambiguous. Are you looking for simply a reminder message (as described in Jonno's answer), or a requirement to fill in the fields, which are prompted, before it will allow you to create the quote? – fixer1234 – 2016-02-03T20:28:46.470

As a requirement to fill in the fields. Thanks for the suggestion, I will edit my question. – rodsarria – 2016-02-03T20:43:38.547

Answers

2

You can use the VBA event Document_Open to achieve this. You will need to save the document as a .docm file for it to work (Word Macro-Enabled Document.)

Press Alt+F11, and add this code to the ThisDocument object:

Sub Document_Open()
    MsgBox "Don't forget to amend the fields!"
End Sub

You can do a lot more than just show a MsgBox of course.

enter image description here

To expand upon this and actually populate data from the prompt, you could use input boxes or a custom form. I'll go through input boxes here, as forms are a bit longer and more complicated.

First, we need to add form fields for the data we actually want to populate. I'll show you the most compatible way to do this.

You may need to enable the Developer toolbar for this. Some instructions to cover different versions of Word are here, for mine, I had to enable it here:

enter image description here

Next, we'll add the form field:

enter image description here

Right click the new form field and click Properties. Give the field a Bookmark that clearly references it:

enter image description here

Now, in VBA, we can change this value using text from an input box:

Sub Document_Open()
    ActiveDocument.FormFields("CompanyName").Result = InputBox("Enter your company name here")
End Sub

You can obviously add as many of these as desired.

enter image description here

Note: The grey background - field shading - does not show up in print, but if you want to remove it you can click your field and click this button in the same place you added it from:

enter image description here

Jonno

Posted 2016-02-03T19:12:43.433

Reputation: 18 756

Nice one. But what if I need to fill in the fields from the pop-up window? Is this possible? – rodsarria – 2016-02-03T20:47:12.883

@rodsarria Yes absolutely. I've added an example of this. – Jonno – 2016-02-04T04:04:54.733

I got a problem. Now, every time I open a Word document, it shows the pop-up window. Can I restrict this only for my quotation document? – rodsarria – 2016-02-16T17:32:50.533

@rodsarria sounds like you added the event handler to 'Normal' instead of your actual document. – Jonno – 2016-02-16T17:44:04.770