View Single Post
 
Old 08-05-2011, 03:35 AM
kosh2 kosh2 is offline Windows 7 32bit Office XP
Novice
 
Join Date: Aug 2011
Posts: 1
kosh2 is on a distinguished road
Default saving a mail merged document after the user edits it.

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
Reply With Quote