none
Word 2010 - Insert Date and Time (Date format)

    Question

  • Hi

    We would like to set the dateformat automatically (see the image below).

    So when the user logs on and goes into Word, it is already set to the format we would like to use as standard.  Is there a registry setting we could populate?

    Many thanks for your help.

    anna


    Anna

    Tuesday, March 06, 2012 12:48 PM

Answers

  • Hi Anna,

    If you put a macro like the following into the document template (eg Normal.dot), and re-assign the Ctrl-Shift-D shortcut to it, then the Ctrl-Shift-D shortcut will insert the date without even needing to use the dialogue.

    Sub InsertDateTime()
    With Selection
      .Collapse wdCollapseStart
      .Text = Format(Now(), "DD/MM/YYYY")
      .Collapse wdCollapseEnd
    End With
    End Sub

    Of course, re-assigning the shortcut means you can't use it to open the dialogue, so you'd have to do access that via Insert|Quick Parts|Field. The alternative is to assign the macro to a different shortcut key combination.

    As written, the code inserts the date at the start of whatever range is selected. If you want the code to replace whatever is selected instead (eg a different date), delete the line '.Collapse wdCollapseStart'.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    • Marked as answer by Bruce Song Wednesday, April 04, 2012 3:15 AM
    Wednesday, March 07, 2012 10:22 AM

All replies

  • Hi Anna,

    There is no registry or Word setting to control that. Of course, if you put a DATE or CREATEDATE field with the required formatting switches into the document's template, that would obviate the need for the user to do anything in that regard when creating a new document.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Wednesday, March 07, 2012 4:42 AM
  • Hi

    Unfortunately thats not possible in this case.  The user is using the out of the box alt+shift+d to insert the current date within the document.  Its a random thing they do so nothing to do with fields.  In all other cases where we are "controlling" the use of the datetime - we code the format so its not a problem in these cases as you mention because these are fields. 

    So the idea is - given they can use the shortcut keys to insert the date, rather than them have to go and set up the format they are used to seeing - we do it for them when they get their image.  But it sounds liek this is impossible?

    anna


    Anna

    Wednesday, March 07, 2012 8:09 AM
  • Hi Anna,

    If you put a macro like the following into the document template (eg Normal.dot), and re-assign the Ctrl-Shift-D shortcut to it, then the Ctrl-Shift-D shortcut will insert the date without even needing to use the dialogue.

    Sub InsertDateTime()
    With Selection
      .Collapse wdCollapseStart
      .Text = Format(Now(), "DD/MM/YYYY")
      .Collapse wdCollapseEnd
    End With
    End Sub

    Of course, re-assigning the shortcut means you can't use it to open the dialogue, so you'd have to do access that via Insert|Quick Parts|Field. The alternative is to assign the macro to a different shortcut key combination.

    As written, the code inserts the date at the start of whatever range is selected. If you want the code to replace whatever is selected instead (eg a different date), delete the line '.Collapse wdCollapseStart'.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    • Marked as answer by Bruce Song Wednesday, April 04, 2012 3:15 AM
    Wednesday, March 07, 2012 10:22 AM