ordendelfai
Technical User
Happy new years everyone!! =)
I am using the below code to do mail merges, and need to find a way to stop word from asking "do you want to save the changes you made to "Form Letters 1" after this code
If WordWasNotRunning = False Then
objWord.Application.Quit
End If
This code makes Word close alright, but the save question is annoying as we do not save our mailmerges.
Thanks =D
Public Function MergeIt1Employee()
Dim objWord As Word.Document
Set objWord = GetObject("S:\Delphi\Templates\ExternalCorrespondence\1EmployeeTermGroup.doc", "Word.Document"
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Access database.
objWord.MailMerge.OpenDataSource _
Name:="C:\Delphi\Delphi.mdb", _
LinkToSource:=False, _
Connection:="TABLE tblMailMerge"
' Execute the mail merge.
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
'The following line must follow the Execute statement because the
'PrintBackground property is available only when a document window is
'active. Without this line of code, the function will end before Word
'can print the merged document.
objWord.Application.Options.PrintBackground = False
objWord.Application.ActiveDocument.PrintOut
If WordWasNotRunning = False Then
objWord.Application.Quit
End If
End Function
I am using the below code to do mail merges, and need to find a way to stop word from asking "do you want to save the changes you made to "Form Letters 1" after this code
If WordWasNotRunning = False Then
objWord.Application.Quit
End If
This code makes Word close alright, but the save question is annoying as we do not save our mailmerges.
Thanks =D
Public Function MergeIt1Employee()
Dim objWord As Word.Document
Set objWord = GetObject("S:\Delphi\Templates\ExternalCorrespondence\1EmployeeTermGroup.doc", "Word.Document"
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Access database.
objWord.MailMerge.OpenDataSource _
Name:="C:\Delphi\Delphi.mdb", _
LinkToSource:=False, _
Connection:="TABLE tblMailMerge"
' Execute the mail merge.
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
'The following line must follow the Execute statement because the
'PrintBackground property is available only when a document window is
'active. Without this line of code, the function will end before Word
'can print the merged document.
objWord.Application.Options.PrintBackground = False
objWord.Application.ActiveDocument.PrintOut
If WordWasNotRunning = False Then
objWord.Application.Quit
End If
End Function