• Default date in form field (Word 2000)

    Author
    Topic
    #420447

    I want the form to show the current date but allow the user to change it. The form is a protected template so simply inserting the a date field does not allow the user to make a change. The form field allows me to format the date and to enter a default, but how can I enter that default as other than a fixed date?

    Viewing 0 reply threads
    Author
    Replies
    • #952087

      Since you are creating a template, you only want the date to be set when the user creates a new document based on the template, I assume. You can do this as follows:
      – Activate the Visual Basic Editor (Alt+F11)
      – Double click the ThisDocument object for your template.
      – Select Document from the dropdown list in the upper left of the module window that appears.
      – Make the code look like this:

      Private Sub Document_New()
      ActiveDocument.FormFields(“Text1”).Result = Date
      End Sub

      – Replace Text1 with the bookmark name of your date form field. (Double click the form field while the template is unprotected to see/set the bookmark name)

      • #952215

        Hans,
        As usual you come through. I had assumed that if I added the date programmatically, it would be changed every time the document was opened, but the way you describe, the date is only added when a new document is created from the template.
        Thanks

        • #952216

          That is correct. The Document_New procedure runs only once during the lifetime of a document: when it is created from its template. There is also a Document_Open event that occurs each time the document is opened; you obviously don’t want to use that to set the date.

    Viewing 0 reply threads
    Reply To: Default date in form field (Word 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: