Emailing a document that is created with mailmerge

A

axelcore

I have created an automated mailmerge using the following code, it is set up
to email the mailmerge, but I can't figure out how to answer to the two
questions it is asking me. First in word it asks, "Opening this document
will run the following SQL command: SELECT * FROM [contacts1] Data
will be placed in the document. Do you want to continue? (I always want to
say yes to this)

Second: A program is trying to access outlook to send an email do you want
to allow this. This message will pop up for as many recipients as i have in
the table so i need some type of loop to continuously answer yes.

All help is much appreciated.

Dim objWord As Word.Document
Set objWord = GetObject("C:\Documents and
Settings\jclark\Desktop\test.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Northwind database.
objWord.MailMerge.OpenDataSource Name:="C:\Documents and
Settings\jclark\My Documents\Flottweg\Engineering\Access files\Access Data
Backup\test.mdb", LinkToSource:=True, Connection:="TABLE Contacts1",
SQLStatement:="SELECT * FROM [contacts1]"
' Execute the mail merge.
objWord.MailMerge.Destination = wdSendToEmail
objWord.MailMerge.Execute
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top