Forum Discussion

ChrisC365's avatar
ChrisC365
Brass Contributor
Jun 25, 2020

Automate adding date to report

Hi

 

I have a simple report which is created using MS Word, each time I use the report I need to change the Month and year, to reflect the current content I am reporting on.  Is there a way to create field for the Month and year values, then when I open the document a popup or user input window appears to allow the user to add these details; Month and a year value.  All fields throughout the document are updated accordingly.  Or alternately, is there a means to ask MS Word to prompt for these details when the document is opened and again update the value throughout the document?

 

Many thanks Chris

  • ChrisC365 

    Before answering directly, I'll say that if you're in the habit of opening a previous month's report and modifying it with new data, that's a poor practice. For one thing, it risks accidentally overwriting the previous report with the new one; if you don't have reliable backups, the previous version of the document is not recoverable. The proper way to use Word is to make a template of the report -- you can do that simply by using File > Save As and changing the file type from .docx to .dotx. Then use the File > New command (or just double-click the template's icon in File Explorer) to base each new document on the template.

     

    To make your Month and Year fields, use the Insert > Quick Parts > Field dialog to insert these two fields at the beginning of the template (or just press Ctrl+F9 to insert the field brackets, and type the text between them):

     

    { FILLIN "Enter month" } { FILLIN "Enter year" } 

     

    Select the two fields and insert a bookmark named Month_Year. Then press Alt+F9 once (or maybe twice) so the field codes disappear.

     

    At each place in the template where you want the month and year to appear, insert this field:

     

    { REF Month_Year }

     

    Save the template and close it.

     

    When you create a new document based on the template, these two boxes will appear first:

     

    When the document appears on the screen, the month and year will appear in the FILLIN fields and all the REF fields.

     

    If you make a mistake and want to change the date, select the whole document (Ctrl+A) and update its fields (F9).

  • Jay Freedman's avatar
    Jay Freedman
    Brass Contributor

    ChrisC365 

    Before answering directly, I'll say that if you're in the habit of opening a previous month's report and modifying it with new data, that's a poor practice. For one thing, it risks accidentally overwriting the previous report with the new one; if you don't have reliable backups, the previous version of the document is not recoverable. The proper way to use Word is to make a template of the report -- you can do that simply by using File > Save As and changing the file type from .docx to .dotx. Then use the File > New command (or just double-click the template's icon in File Explorer) to base each new document on the template.

     

    To make your Month and Year fields, use the Insert > Quick Parts > Field dialog to insert these two fields at the beginning of the template (or just press Ctrl+F9 to insert the field brackets, and type the text between them):

     

    { FILLIN "Enter month" } { FILLIN "Enter year" } 

     

    Select the two fields and insert a bookmark named Month_Year. Then press Alt+F9 once (or maybe twice) so the field codes disappear.

     

    At each place in the template where you want the month and year to appear, insert this field:

     

    { REF Month_Year }

     

    Save the template and close it.

     

    When you create a new document based on the template, these two boxes will appear first:

     

    When the document appears on the screen, the month and year will appear in the FILLIN fields and all the REF fields.

     

    If you make a mistake and want to change the date, select the whole document (Ctrl+A) and update its fields (F9).

Resources