Results 1 to 13 of 13
  1. #1
    Lounger
    Join Date
    Jan 2003
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Insert Date field (2002)

    I would like to have the date field in a Word template automatically update to the current date.
    But I would like the date on the document created from that template not to update (i.e., to keep the date on which it was created).
    How can I do it?

  2. #2
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Wisconsin, USA
    Posts
    193
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Insert Date field (2002)

    You can insert a "create date" field. When the template is first used it will put in the current date but that date won't change when opened on a different date.

  3. #3
    Lounger
    Join Date
    Jan 2003
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Insert Date field (2002)

    Thanks Leanne but I want the date on the template to change whenever it is opened so the person using the template starts with the current date. It is the date on the document created from the template that I want to remain fixed.

  4. #4
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Wisconsin, USA
    Posts
    193
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Insert Date field (2002)

    On my templates when the template comes up after doing File, New, the date will show as the current date and will not change if revisions are made later. It does not matter if my templates are protected or not.

    {CREATEDATE @ "MMMM/d/yyyy" * MERGEFORMAT}

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Insert Date field (2002)

    Okay, the preferred way to have users work with templates is to generate new documents from them using File>New rather than opening them directly. So Leanne's solution is best in that scenario. It works becuase the CREATEDATE field is copied into the newly created document and reflects the date of creation of that document.

    If, on the other hand, you want a date in your template that reflects the "last modified" date of the template itself, and have that carry over unchanged into the document, I'm not sure if there is a single field that will do this for you automatically. Instead, the user editing the template might need to use a regular DATE field, unlock it, update it, and lock it again. I think ('though I have not tested this) that documents created from the template will inherit the field as locked. You could need to create an AutoOpen macro in your template to automate this, or even to find and replace a static text string marked with a bookmark.

    Does this make sense?

  6. #6
    Lounger
    Join Date
    Jan 2003
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Insert Date field (2002)

    Thanks Leanne and jscher.

    The document created from the template is inheriting the date field in the template that updates automatically to the current date. That is to say, I access the template correctly on the 1st, and save (save as) the document created from the template. When I open the document saved on the 1st, the date shows as the 5th. This may be a function of the fact that the template is coming from database program (Wind2 Award) that interfaces with Word for its templates.

    If there is no easy way to have the template open with today's date but have the document created from it keep its creation date, I'll just put a fixed date in the template. I do not know how to create an AutoOpen macro in the template to automate this, or how to find and replace a static text string marked with a bookmark.

    Thanks for your thoughts.

  7. #7
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Wisconsin, USA
    Posts
    193
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Insert Date field (2002)

    Are you able to access the template by opening it and changing the date field to a create date field? If so, that is what should be done. If you are not able to make changes to the template I'd try the following macro. Select the date first then run the macro. The macro will insert the current date then select the date and change it to text rather than a field.

    Sub ChangeDatetoCurrentDate()
    '
    ' ChangeDatetoCurrentDate Macro
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
    "DATE @ ""MMMM d, yyyy""", PreserveFormatting:=True
    Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
    Selection.Fields.Unlink
    Selection.HomeKey Unit:=wdLine
    End Sub

    Hope this helps.

  8. #8
    Lounger
    Join Date
    Jan 2003
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Insert Date field (2002)

    Leanne: I can access the template and make changes to it.

    Sorry to be dense but when I insert the date field into the template and toggle "update automatically" the template shows the current date for everyone that opens "create document" which is the equivalent of File, New. If I do not toggle "automatically update" the template opens to the last date the template was modified. Fair enough.

    The problem is the users want to see the current date in the template each time they access it but want the document they create from the template to keep the date they created it because the template under discussion is a contract.

    I think you are suggesting that they run a macro each time they create a document from the template. In this particular case, I think it would be easier to just tell them to change the date.

    Thanks for your help (and all your code typing!).

  9. #9
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Insert Date field (2002)

    Can you use a complicated IF field solution? The attached uses a peculiarity of the Document Properties: the Template property shows the name of a template itself when that template is open. Thus, the field does this (roughly):

    If {DOCPROPERTY "Template"} = {FILENAME} Then {DATE} Else {CREATEDATE}
    Attached Files Attached Files

  10. #10
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Insert Date field (2002)

    Hi ssb:
    I don't know if you ever solved this. I'm not a VBA expert, but use a solution that works quite easily, even if it's crude. I insert a {Date} field in the template, formatted the way I want. I don't lock it. However, I create documents based on it using File/New. The template contains the following AutoNew macro, which selects the field (which has the creation date), locks it so it won't update, & then moves to the next field. You may have to modify it if your date field isn't the first field in the template or if you don't have any other fields in the document. The beauty of the solution is that the creation date is entered into the new contract, but if it takes you a week to finish it & you want the date to reflect the finished date, simply unlock the field (Ctrl+Shift+F11), update the field (F9), & relock it (Ctrl+F11).

    Basically, without knowing any VBA, you can open the template and record a macro (which you name AutoNew) that goes to the date field (press F11 to do this), locks the field (press Ctrl+F11 to do this), & then places the cursor where you want. The macro is:<pre>Sub AutoNew()
    '
    ' CreateDate Macro
    ' Macro recorded 8/13/03 by Phil Rabichow
    '
    Selection.NextField.Select
    Selection.Fields.Locked = True
    Selection.NextField.Select
    End Sub</pre>

    Hope this helps,

  11. #11
    Lounger
    Join Date
    Jan 2003
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Insert Date field (2002)

    Thanks Phil. I'll give it a try.

  12. #12
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wetherby, Yorkshire, England
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Insert Date field (2002)

    If you select the date field after creating the document and press Ctrl+Shift+F9 the date is fixed.
    Peter

  13. #13
    Lounger
    Join Date
    Jan 2003
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Insert Date field (2002)

    Thank you Peter; it works like a charm and is simple to teach.

Posting Permissions

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