• AutoInsert Date

    Author
    Topic
    #353886

    Hi,

    I want a template to auto-insert the date from the system clock in Word2000 – how can I do that?
    This should only happen when I trigger the template from a toolbar macro button. It should not happen each time the file is opended for editing by any user.

    Thanks v. much,

    m.q.

    Viewing 5 reply threads
    Author
    Replies
    • #518706

      Dear Musab

      First create a bookmark at the point where the date is to be inserted.
      Next, write the following macro:

      Sub Macro1()

      ‘ Macro1 Macro
      ‘ Macro recorded 3/14/01 by Rajesh

      Selection.GoTo What:=wdGoToBookmark, Name:=”Date”
      Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
      “DATE @ “”dd MMMM yyyy”””, PreserveFormatting:=True
      End Sub

      Lastly, assign this macro to an icon on your template toolbar.

      Trust this will meet your need.

      Cheers

    • #518709

      If you want the template to insert the date automatically every time a new document based on that template, you should create the macro in the ThisDocument object of the template as follows :

      Private Sub Document_New()
      Selection.GoTo What:=wdGoToBookmark, Name:=”Date”
      Selection.InsertDateTime DateTimeFormat:=”d MMMM, yyyy”, InsertAsField:=False
      Selection.HomeKey Unit:=wdStory
      End Sub

      This macro only runs in the event of a new document being created, and does not run if you open an existing document based on the template. You nee to make sure you have a Bookmark called Date for the above example to run. You can of course change that to whatever suits, or remove the first line altogether. You can also alter the Date Format picture to whatever format you use.

      This inserts the date as a static value, i.e it is not updated. If you want the time entered as a field change InsertAsField:=False to InsertAsField:=True, and the time will update to the current time.

      Hope that works for you

      Andrwe C

    • #518728

      However, having the field there makes it a problem if you do need to change the date. For example, I create a letter and save it to disk. Two weeks later I actually get around to printing and mailing the letter, so I have to change the date. That’s much easier if the date is in there as just text.

    • #518733

      No, I didn’t miss what you were saying (I did not write the initial question). In my case, I would want to insert the create date, and I would not want it to change automatically. All I am saying is that I would prefer to have the date inserted as text, not in a field, so that if I do need to change it I can change just the part of the date that needs to be changed. For example, if all I need to change is the day of the month, I don’t have to delete the field and retype the entire date.

      • #518987

        Hi Legare:

        Another way to insert the date, that I like, is to insert it as a field & then lock it. I have the date field locked in my template. Whenever I create a new document based on that template, the current date is entered, but in a locked field. If it takes me two weeks to finish the letter, I just unlock the field & update it, then lock it again.

        • #518998

          What is the advantage of having it in a field, locked or unlocked, vs plain text if it is a fixed value that is not going to change?

          • #519033

            I’m assuming that it can change. By having it in a letter template, for example, letters that are written & mailed the same day, have the current date. Letters (or whatever) that take several days can be changed to the date of mailing. And if you need to resend the letter months later with a new date, you can unlock the field, print it, & close it without saving. In the long run, it’s probably just a matter of preference, as it takes very little time to change a date.

            • #519037

              Bu a file has only one create date. Therefore, if you insert a field with the create date, it should never change. If the field is print date, or save date, or current date, etc., then yes those do change and it makes sense to have those in a field. If I am going to insert the create date, I prefer to use a macro to insert it as text because that is much less trouble to change manually when I have to change it. If I need to change the date from 25 December 2001 to 26 December 2001, I just have to hilite one character and type one character. If it was a create date field, I would have to delete the field and type the entire date.

            • #519132

              Hi Legare:

              I wasn’t referring to the create date. The field I use is the current date. This has the flexibility of being the create date for documents which take only 1 day to write, the save or print date for documents which take more than 1 day to finish or for those that I wish to resend with a new date.

              If you start a letter on 25 December 2001, that date is inserted automatically. If you print & it on 2 January 2002, then it’s not difficult to unlock & print it, which updates the field. I can then lock it again.

              In any event, those are the advantages that I see to using it; it’s certainly not the only way. I, too, use macros to insert the current date as text, both in long & short form.

        • #519023

          Phil,

          Another question related to Legare’s: How can one tell whether or not a field is locked?

          • #519034

            You can put the mouse over it & right click; if it’s locked, there won’t be an update option. But you raise a good point. I wish there were a visual way to know; like a different shading.

            • #519050

              Thanks for that tip, Phil. It’s useful to be reminded of the right mouse click, and the extrra options it offers.

    • #519129

      I only ever use SaveDate.
      This gives the date I last saved the document – surely the meaningful date for the letter & it auto updates if I revise the letter – but not if I don’t!

    • #519135

      Well, you’re not old until you no longer remember “those days”

    Viewing 5 reply threads
    Reply To: AutoInsert Date

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

    Your information: