By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 1,367 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

Need help w/mail merge code

P: n/a
Hi All,
This code is running in WinNT/Access97. I'm looking for some help with
getting this code to do two(2) things better then it does now and I'm
not sure how to do it.
1. On the 'objWord.Application.Quit' statement, it asks if I want to
save changes and I would like it to not ask that and I don't know what
the exact code is to do that.

2. On the 'objWord.MailMerge.Execute' statement the printer dialog
window pops up and I have to click Ok in order for it to start
printing, how do I pass the OK click to the printer dialog box? I was
thinking something like BackgroundPrinting=OK but, again I don't know
what the exact code is.
Thanks for any and all help
bobh.

Dim objWord As Word.Document
Set objWord = GetObject("\\Homafsf6\Vol2\Breakpoint\Documentatio n\BPPaymentLtr.doc",
"Word.Document")
'make Word visible.
objWord.Application.Visible = True
'set the mail merge data source as the database containing the mail
merge data.
objWord.MailMerge.OpenDataSource _
Name:="\\Homafsf6\Vol2\Breakpoint\Data\BreakpointD b.mdb", _
LinkToSource:=True, _
Connection:="Table tblApprovedLetters", SQLStatement:="Select *
from [tblApprovedLetters]"
'execute the mail merge.
objWord.MailMerge.Destination = wdSendToPrinter
objWord.MailMerge.Execute
'close the Word application
objWord.Application.Quit
Set objWord = Nothing
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Bob Hynes wrote:
Hi All,
This code is running in WinNT/Access97. I'm looking for some help with
getting this code to do two(2) things better then it does now and I'm
not sure how to do it.
1. On the 'objWord.Application.Quit' statement, it asks if I want to
save changes and I would like it to not ask that and I don't know what
the exact code is to do that.
In my code, I have an application object (word) and a document objenct (Test.doc) I
close the code with
worddoc.save
workdoc.close (false)
2. On the 'objWord.MailMerge.Execute' statement the printer dialog
window pops up and I have to click Ok in order for it to start
printing, how do I pass the OK click to the printer dialog box? I was
thinking something like BackgroundPrinting=OK but, again I don't know
what the exact code is.
Thanks for any and all help
bobh.


From wordhelp, thie following will print the 1st 3 pages of the doc in the active window

ActiveDocuent.PrijntOut Range:=wdPrintFromTo, Form:="1", To:="3"

You may want to subscribe to newsgroups like public.microsoft.word.vba and
public.microsoft.word.beginners. Lost of folks there that are glad to help.
Nov 12 '05 #2

P: n/a
Thanks for the try put your suggestion do not work in my code. I will
however look in the Word forum.
bobh.

Salad <oi*@vinegar.com> wrote in message news:<40***************@vinegar.com>...
Bob Hynes wrote:
Hi All,
This code is running in WinNT/Access97. I'm looking for some help with
getting this code to do two(2) things better then it does now and I'm
not sure how to do it.
1. On the 'objWord.Application.Quit' statement, it asks if I want to
save changes and I would like it to not ask that and I don't know what
the exact code is to do that.


In my code, I have an application object (word) and a document objenct (Test.doc) I
close the code with
worddoc.save
workdoc.close (false)
2. On the 'objWord.MailMerge.Execute' statement the printer dialog
window pops up and I have to click Ok in order for it to start
printing, how do I pass the OK click to the printer dialog box? I was
thinking something like BackgroundPrinting=OK but, again I don't know
what the exact code is.
Thanks for any and all help
bobh.


From wordhelp, thie following will print the 1st 3 pages of the doc in the active window

ActiveDocuent.PrijntOut Range:=wdPrintFromTo, Form:="1", To:="3"

You may want to subscribe to newsgroups like public.microsoft.word.vba and
public.microsoft.word.beginners. Lost of folks there that are glad to help.

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.