I produce a mail merge document from an Access database. The user can then further add to this document. I then want to intercept the documentclose event and prompt the user to save the file. (Note. pressing the save button alone overwrites a file.) I found the following script which I placed in the mail merge document but I now fealise that this script does not get copied over to the merged document. I placed the script in a template but it does not execute.
I am now lost.
Code:
Private Sub DocumentBeforeClose()
On Error GoTo errorIn
ActiveDocument.BuiltInDocumentProperties("Title") = InputBox("Please enter a file name (use the patient name)")
Dim Today, FolderName$, NameofFile$, FullFileName$
FolderName$ = "S:\PaedCom\cardex\"
NameofFile$ = ActiveDocument.BuiltInDocumentProperties("Title")
FullFileName$ = FolderName$ + NameofFile$
ActiveDocument.SaveAs FileName:=FullFileName$, FileFormat:=wdFormatDocument
MsgBox ("This has been saved in PAEDCOM/cardex directory under their name")
Exit Sub
errorIn:
MsgBox ("there is an eror.")
End Sub