Hi
I have the following module called 'MergeIt'
it works great, except that it doesn't quit Microsoft Word, with no save prompt as I'd like it too. I've tried loads of things such as objWord.Quit etc, nothing works!!!
The new document it creates is called Labels1
Is this causing the problem?
Any help much appreciated
Steph
I have the following module called 'MergeIt'
it works great, except that it doesn't quit Microsoft Word, with no save prompt as I'd like it too. I've tried loads of things such as objWord.Quit etc, nothing works!!!
The new document it creates is called Labels1
Is this causing the problem?
Any help much appreciated
Steph
Code:
Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("\\berlin\labels.doc", "Word.Document")
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource _
name:="\\berlin" & _
"\test.mdb", _
LinkToSource:=True, _
Connection:="QUERY labels", _
SQLStatement:="Select * from [Table1]"
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
objWord.Application.Options.PrintBackground = False
objWord.Application.ActiveDocument.PrintOut
'objWD.Quit
MsgBox "Mail merge successful", vbInformation, "Mail Merge"
End Function