Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Feb 2001
    Location
    Toronto, Ontario, Canada
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default date in form field (Word 2000)

    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?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Default date in form field (Word 2000)

    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)

  3. #3
    Lounger
    Join Date
    Feb 2001
    Location
    Toronto, Ontario, Canada
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Default date in form field (Word 2000)

    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

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Default date in form field (Word 2000)

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •