PC Review


Reply
Thread Tools Rate Thread

Automating Mail Merge

 
 
=?Utf-8?B?RWQgU2hhbmxleQ==?=
Guest
Posts: n/a
 
      28th Feb 2005
I've got a database that has about 60 queries based upon various fields that
the user selects on a form. I would like to run a mail merge based upon
these fields and a text field where the user enters the path of the Word
document. I currently have the path defined in the field "txtMergeFile" and
have the proper query defined in "MergeQuery". Can anyone help me in
figuring out how to do this?

Thanks.


 
Reply With Quote
 
 
 
 
JohnR
Guest
Posts: n/a
 
      1st Mar 2005
Dim wrdApp As Object
Dim P1 As Object
Dim PM As Object
On Error Resume Next 'Get WOrd Object
Set wrdApp = GetObject(, "Word.Application")
If err Then
Set wrdApp = CreateObject("Word.Application")
End If
wrdApp.Activate
wrdApp.Visible = False
Set PM = wrdApp.Documents.Open(txtMergeFile)
With PM.MailMerge
.OpenDataSource name:=dbMerge, LinkToSource:=True,
Connection:="QUERY MergeQuery", _
SQLStatement:="Select * from [MergeQuery]"
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
Set P1 = wrdApp.ActiveDocument 'New Merged Document
PM.Close False 'Close Merge Template
P1.SaveAs FileName:="Path and Filename" 'Save New Document
p1.close
Set wrdApp = Nothing
Set P1 = Nothing
Set PM = Nothing

"Ed Shanley" <(E-Mail Removed)> wrote in message
news:F5DB3E37-E8CC-4F0F-8D70-(E-Mail Removed)...
> I've got a database that has about 60 queries based upon various fields
> that
> the user selects on a form. I would like to run a mail merge based upon
> these fields and a text field where the user enters the path of the Word
> document. I currently have the path defined in the field "txtMergeFile"
> and
> have the proper query defined in "MergeQuery". Can anyone help me in
> figuring out how to do this?
>
> Thanks.
>
>



 
Reply With Quote
 
Tom
Guest
Posts: n/a
 
      1st Mar 2005
Ed

Take a look at:

http://www.members.shaw.ca/AlbertKal.../msaccess.html

Tom
"JohnR" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Dim wrdApp As Object
> Dim P1 As Object
> Dim PM As Object
> On Error Resume Next 'Get WOrd Object
> Set wrdApp = GetObject(, "Word.Application")
> If err Then
> Set wrdApp = CreateObject("Word.Application")
> End If
> wrdApp.Activate
> wrdApp.Visible = False
> Set PM = wrdApp.Documents.Open(txtMergeFile)
> With PM.MailMerge
> .OpenDataSource name:=dbMerge, LinkToSource:=True,
> Connection:="QUERY MergeQuery", _
> SQLStatement:="Select * from [MergeQuery]"
> .Destination = wdSendToNewDocument
> .SuppressBlankLines = True
> With .DataSource
> .FirstRecord = wdDefaultFirstRecord
> .LastRecord = wdDefaultLastRecord
> End With
> .Execute Pause:=False
> End With
> Set P1 = wrdApp.ActiveDocument 'New Merged Document
> PM.Close False 'Close Merge Template
> P1.SaveAs FileName:="Path and Filename" 'Save New Document
> p1.close
> Set wrdApp = Nothing
> Set P1 = Nothing
> Set PM = Nothing
>
> "Ed Shanley" <(E-Mail Removed)> wrote in message
> news:F5DB3E37-E8CC-4F0F-8D70-(E-Mail Removed)...
>> I've got a database that has about 60 queries based upon various fields
>> that
>> the user selects on a form. I would like to run a mail merge based upon
>> these fields and a text field where the user enters the path of the Word
>> document. I currently have the path defined in the field "txtMergeFile"
>> and
>> have the proper query defined in "MergeQuery". Can anyone help me in
>> figuring out how to do this?
>>
>> Thanks.
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automating mail merge from excel Cheese_whiz Microsoft Excel Programming 3 14th Nov 2008 04:07 PM
Re: Automating mail merge? Ken Slovak - [MVP - Outlook] Microsoft Outlook VBA Programming 0 6th Sep 2005 03:19 PM
Automating Mail Merge query =?Utf-8?B?U3RlcGhhbmll?= Microsoft Access Queries 1 18th Jul 2005 07:17 PM
Real problems automating a mail merge nath Microsoft Excel Programming 0 10th Jun 2004 11:32 AM
Automating mail merge =?Utf-8?B?TUg=?= Microsoft Access Macros 1 6th May 2004 09:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:38 PM.