473,322 Members | 1,398 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

To run several Word mail merges from Access

I use MS Office 2003 and would like to run several Word mail merges
from Access.

My code so far is given below.

1. The code does not do what I want. I want to save the new document
with the merge result, not the merge template I start out with. At the
moment it saves the latter.

2. I would like all Word documents to be closed in the end.

3. I would like to run several queries and for each of them do a mail
merge to a new document that is being saved.

Any help with 1-3 would be most welcome.

Regards,

Jan Nordgreen

---

Option Compare Database

'References: Microsoft Word 11 Object Library

Private Sub Command0_Click()

' variables
Dim folder As String
folder = "G:\GIS\school administration\reports\"
Dim template As String
template = "report template.doc"
Dim database As String
database = "create report documents.mdb"
Dim objWord As Word.Document
Set objWord = GetObject(folder & template, "Word.Document")

' Make Word visible.
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource _
Name:=folder & database, _
LinkToSource:=True, _
Connection:="TABLE Test", _
SQLStatement:="SELECT * FROM [Test]"

' Execute the mail merge.
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute

' Save the document
objWord.SaveAs FileName:=folder & "7.doc",
FileFormat:=wdFormatDocument, _
LockComments:=False, Password:="", AddToRecentFiles:=True,
WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False,
SaveAsAOCELetter:= _
False

' Release the object variable.
objWord.Close
Set objWord = Nothing

End Sub
Nov 11 '08 #1
1 2330
damezumari <ja**********@gmail.comwrote:
>I use MS Office 2003 and would like to run several Word mail merges
from Access.

My code so far is given below.
See Albert Kallal's Super Easy Word Merge - Scroll down a ways
http://www.members.shaw.ca/AlbertKal.../msaccess.html

No code required on your part as his tool as all the code needed.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Nov 11 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dan Nash | last post by:
Hi guys I wonder if you could help. I'm trying to create a bespoke interface for mail merging from an Access database in Word. At the moment, I'm just trying it with CSV files, and it works....
3
by: Andy | last post by:
I am trying to do the following from an ASP.NET Web Application (C#). User fills out a form. The program takes those answers and merges them with a WORD document. I have tried the few examples...
1
by: S Taylor | last post by:
I am running MSWord VBA code from within Access VBA that merges a Word mail merge document to the printer, using data in Access. In Office 97 it worked fine, but in Word 2003 a new message comes up...
6
by: Tom Keane | last post by:
Sorry if I'm posting this in here, but this seems to be tonnes more active than the Word newsgroup. And I'm sure there's someone here that can help me out. I have a document set up in word...
1
by: darnnews | last post by:
I have set up a mail merge to create blocks that will look like this: New York Times, 6/22/1989. Circulation: 1,200,000 "Headline," by Author. Description. URL. Two problems I am having:
6
by: Simon | last post by:
on my frmCustomer form i would like a button that open up words and runs a mail merger only with the data on on that form ( as on the mail merger i just want the customer address for when i write a...
6
by: crealesmith | last post by:
Firstly, I have no problem with mail merging to Word, VB code for that works perfectly. On one mail merge I need to merge 15 fields of data that are from 3 seperate records. The 3 records are all...
1
by: kirkus84 | last post by:
I am currently trying to do a multiple record mail merge through a query via a command button on a form. The query basically displays customers who have said yes to privacy. The user inputs a date...
1
by: kayberrie | last post by:
I want to write a VBA mail merge code. I want to link the code/macro/dohicky to a nifty little button so it makes life easy. I think I can handle the button part, the code part - not so much. I know...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.