Consulting

Results 1 to 2 of 2

Thread: VBA autosave new doc

  1. #1

    Question VBA autosave new doc

    Iím not sure this is possible but thought it couldnít hurt to ask. I have a mail merge. My data source in Excel automatically saves a copy. My Word merge document automatically merges and leaves you with the finished product ready to print. Is it possible to automatically save the finished product with a date stamp to a precreated Back up folder without messing with the Normal template? Maybe within the code of the merge doc before it closes without saving and makes the letters doc active?

    thank you!

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    3,483
    Location
    You might adding something like the following to your mailmerge main document:
    Sub MailMergeToDoc()
    Application.ScreenUpdating = False
    Dim StrNm As String: StrNm = Split(ActiveDocument.Name, ".doc")(0) & " "
    Const StrPath As String = "C:\filepath\"
    ActiveDocument.MailMerge.Execute
    ActiveDocument.SaveAs2 FileName:=StrPath & StrNm & Format(Now(), "YYYYMMDD") & ".docx", _
      FileFormat:=wdFormatXMLDocument, AddToRecentFiles:=False
    Application.ScreenUpdating = True
    End Sub
    Change '
    C:\filepath' to your preferred path.
    Cheers
    Paul Edstein
    [MS MVP - Word]

Posting Permissions

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