Avatar of bejhan
bejhan

asked on 

Automate MS Word Mail Merge (Almost working)

I modified the automated mail merge from http://www.tek-tips.com/faqs.cfm?fid=3237. Everything works how I want it to except when I run this a prompt still appears even though no information needs to be changed. I want to know how to stop this prompt from appearing.
Private Sub cmdMerge_Click()
Dim objWord As Word.Application
Dim objDoc As Word.Document
 
    Set objWord = New Word.Application
    Set objDoc = objWord.Documents.Open("C:\Documents And Settings\bejhan.jetha\Desktop\Initial Letter.doc")
 
    objDoc.MailMerge.OpenDataSource Name:=CurrentProject.FullName, LinkToSource:=True, AddToRecentFiles:=False, Connection:="TABLE table", SQLStatement:="SELECT * FROM table"
 
    objDoc.MailMerge.Destination = wdSendToNewDocument
    objDoc.MailMerge.Execute
 
    objWord.Application.Documents(1).SaveAs ("C:\Documents and Settings\bejhan.jetha\Desktop\Trial Merge.doc")
    
    objWord.Application.Documents(2).Close wdDoNotSaveChanges
    
    Set objWord = Nothing
    Set objDoc = Nothing
End Sub

Open in new window

prompt.bmp
Microsoft Access

Avatar of undefined
Last Comment
Leigh Purvis

8/22/2022 - Mon