Consulting

Results 1 to 3 of 3

Thread: Getting a Word Doc to save itself with today's date in the file name

  1. #1
    VBAX Newbie
    Joined
    Jul 2018
    Posts
    2
    Location

    Cool Getting a Word Doc to save itself with today's date in the file name

    Good afternoon,

    I would like users to be able to open a generic word document and trigger a macro which would automatically save the file with today's date, so there's a copy of the file for each day which can be referred back to later.

    I have recorded a macro which does the saving (below), but I don't know how to get it to use today's date as the file name.

    Any help gratefully received



    Sub SaveAs()
    '
    ' SaveAs Macro
    '
    '
    ChangeFileOpenDirectory _
    "\\SB1VMHOM02\home$\OveryA\Desktop\SCSM Report\Reports"
    ActiveDocument.SaveAs2 FileName:= _
    "\\SB1VMHOM02\home$\OveryA\Desktop\SCSM Report\Reports\2017-07-31.docm", _
    FileFormat:=wdFormatXMLDocumentMacroEnabled, LockComments:=False, _
    Password:="", AddToRecentFiles:=True, WritePassword:="", _
    ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
    SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
    False, CompatibilityMode:=14
    End Sub

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    2,822
    Location
    See if this change works:

    "\\SB1VMHOM02\home$\OveryA\Desktop\SCSM Report\Reports" & Format(Now, "YYYY-MM-DD") & ".docm", _
    Greg

    Visit my website: http://gregmaxey.com

  3. #3
    VBAX Newbie
    Joined
    Jul 2018
    Posts
    2
    Location
    Quote Originally Posted by gmaxey View Post
    See if this change works:

    "\\SB1VMHOM02\home$\OveryA\Desktop\SCSM Report\Reports" & Format(Now, "YYYY-MM-DD") & ".docm", _
    It works!!!! Thank you ever so much.

Posting Permissions

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