Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2004

Tip: Looking for answers? Try searching our database.

vba automation to word 2003 (controlling application Access 2003/2000); sample code?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Philip Leduc - 23 Dec 2004 21:47 GMT
I have an issue doing a simple mailmerge from Access; while using a query.
(either by using ODBC or ole datasource)
The code I use basically just let's word start a mailmerge document and
merge the document
I already solved one issue (Disabling SQL warning)
(http://www.support.microsoft.com/?kbid=825765) and this code runs with a
regular query.

The problem is that I want to use a query that is behind a subform and
changes the records when browsing through the records of the main form.
The code is started from that mainform and should only merge the records
that you can see on that subform.
Using the same query filtered with a field on the form; the mailmerge
document does not open not from the code, neither directly.

There must be different code available to enable to run the mailmerge from
Access in such a way that the data can be filtered according to form
fields??
If somebody has some sample code available and would send it me; that would
make me a happy programmer!

Philip

ps code, see below

'create word object and do mailmerge
   If CreateWordObj() Then
       With gobjWord
           '.Visible = True
           .Documents.Open strDocumentPath
           DoEvents
           With gobjWord.ActiveDocument.MailMerge
               .Destination = wdSendToNewDocument
               .SuppressBlankLines = True
               .Execute
           End With
           .ActiveDocument.PrintPreview
           .Visible = True
       End With
   End If
Doug Robbins - Word MVP - 25 Dec 2004 00:49 GMT
Check out: the one click mailmerge from Access utility on fellow MVP Albert
D Kallal's website at:

http://www.attcanada.net/~kallal.msn/msaccess/msaccess.html

You can modify it so that it interates through each of the records displayed
on your subform to print each one.

Signature

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested.  Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP

> I have an issue doing a simple mailmerge from Access; while using a query.
> (either by using ODBC or ole datasource)
[quoted text clipped - 36 lines]
>         End With
>     End If
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.