Log in

View Full Version : [SOLVED:] VBA autosave new doc



awsmepossum
07-10-2018, 06:01 PM
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!

macropod
07-10-2018, 08:51 PM
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.