Mail Merge with word Automatical

S

Simon

I have a button on my form that runs the code below which will open up
a mailmerge doc and print it automaticaly

when i run it it brings up a message
' Opening this document will run the following SQL command
SELCT *FROM [qryBrochure]
Data from your database will be placed in the document. DO you want to
continue?

I then click YES eevery time. Is there a way for it to select yes every
time automatical

Other little thing is that once the document has been printed
automatiucal is there a way to get Word to exit


Thanks

Simon



Dim objWord As Word.Document
Set objWord = GetObject("C:\Documents and Settings\Simon\My
Documents\BroLetterTest.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\Simon\My Documents\Hot Tubs 2
Buy\Database\Hot Tubs 2 Buy sql.mdb", _
LinkToSource:=True, _
Connection:="Query qryBrochure", _
SQLStatement:="SELECT * FROM [qryBrochure]"
objWord.MailMerge.Destination = wdSendToPrinter
objWord.MailMerge.Execute
 
S

Simon

How do u set warnings to off

I am new to all this VB

Thanks said:
Have you tried to SetWarnings Off?

Simon said:
I have a button on my form that runs the code below which will open up
a mailmerge doc and print it automaticaly

when i run it it brings up a message
' Opening this document will run the following SQL command
SELCT *FROM [qryBrochure]
Data from your database will be placed in the document. DO you want to
continue?

I then click YES eevery time. Is there a way for it to select yes every
time automatical

Other little thing is that once the document has been printed
automatiucal is there a way to get Word to exit


Thanks

Simon



Dim objWord As Word.Document
Set objWord = GetObject("C:\Documents and Settings\Simon\My
Documents\BroLetterTest.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\Simon\My Documents\Hot Tubs 2
Buy\Database\Hot Tubs 2 Buy sql.mdb", _
LinkToSource:=True, _
Connection:="Query qryBrochure", _
SQLStatement:="SELECT * FROM [qryBrochure]"
objWord.MailMerge.Destination = wdSendToPrinter
objWord.MailMerge.Execute
 
M

MBSNewbie

If you are writing a Macro

Start the 1st line with SetWarnings > No

If It's a VB Module:

DoCmd.SetWarnings False



Simon said:
How do u set warnings to off

I am new to all this VB

Thanks said:
Have you tried to SetWarnings Off?

Simon said:
I have a button on my form that runs the code below which will open up
a mailmerge doc and print it automaticaly

when i run it it brings up a message
' Opening this document will run the following SQL command
SELCT *FROM [qryBrochure]
Data from your database will be placed in the document. DO you want to
continue?

I then click YES eevery time. Is there a way for it to select yes every
time automatical

Other little thing is that once the document has been printed
automatiucal is there a way to get Word to exit


Thanks

Simon



Dim objWord As Word.Document
Set objWord = GetObject("C:\Documents and Settings\Simon\My
Documents\BroLetterTest.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\Simon\My Documents\Hot Tubs 2
Buy\Database\Hot Tubs 2 Buy sql.mdb", _
LinkToSource:=True, _
Connection:="Query qryBrochure", _
SQLStatement:="SELECT * FROM [qryBrochure]"
objWord.MailMerge.Destination = wdSendToPrinter
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