472,961 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,961 software developers and data experts.

Need help w/mail merge code

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
2 2465
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Steve M | last post by:
I'm trying to do invoke the mail merge functionality of MS Word from a Python script. The situation is that I have a template Word document, and a record that I've generated in Python, and I want...
2
by: William Wisnieski | last post by:
Hi Everyone, Access 2000 I have some code behind a button that performs a word merge with a query data source. The merge works fine. But what I'd like to do somehow is after the merge is...
2
by: Aaron | last post by:
hello, i am perfoming a mail merge with the following code. Public Function MergeIt() Dim objWord As Object Set objWord = GetObject("C:\MyMerge.doc", "Word.Document") ' Make Word visible....
1
by: Lisa | last post by:
I have a query named QryDept where one of the fields is DeptID. The query is used for the data source of a mail merge letter. I would like to control which department is to get the mail merge...
8
by: Squirrel | last post by:
Hi everyone, I've created a mail merge Word doc. (using Office XP) , the data source is an Access query. Functionality I'm attempting to set up is: User sets a boolean field to true for...
9
by: Neil Ginsberg | last post by:
I have a strange situation using Access to automate a Word mail merge. Using Access 2000 and Word 2000, the code opens Word, opens the document in Word, sets a table in the calling Access...
3
by: ljungers | last post by:
I need to make some changes to a Query/select/print report using word application. What I need to do is change the way Word is called yet keep the process the same. Word is used so changes can be...
7
by: =?Utf-8?B?QmFkaXM=?= | last post by:
Hi, I'm trying to follow a mail merging example in C#.Net that I got from: http://support.microsoft.com/default.aspx/kb/301659 and in one the methods: Word.Application wrdApp; Word._Document...
0
by: truptidalia | last post by:
Hi, I am not that experienced in VB.NET. I am working on a application where i have to perform mail merge from the application. The application lets the userwrite letters, save them as rtf...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.