Solved: Access 2003 mail merge VBA

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

karlhaywood

Thread Starter
Account Closed
Joined
Jan 17, 2010
Messages
680
Hi,

Im trying to merge into a word doc. In the access databse there is a table that consists of

Prefix
FirstName
LastName
Add1
City
PostCode
Recommended By
Area they live in
He/She

I was wonder if anyone can help me with the VBA for the button?

Thanks in advance.
 

OBP

Joined
Mar 8, 2005
Messages
19,895
Have you looked at a mail merge from Word?
Do you want to send one email or a lot of emails?
 

karlhaywood

Thread Starter
Account Closed
Joined
Jan 17, 2010
Messages
680
To everyone in the table around about 200-300. I have used the mail merge in word before but, i would like it all to be done from the Access database, if possible.
 

OBP

Joined
Mar 8, 2005
Messages
19,895
OK, you need Click Yes for this, especially if you want to personalise the letters.
You also need a Word Template with Bookmarks set where you want the data to go into.
 

karlhaywood

Thread Starter
Account Closed
Joined
Jan 17, 2010
Messages
680
I know how to do the bookmarks but dont know how to write the vba. Could you help me with that?
 

OBP

Joined
Mar 8, 2005
Messages
19,895
I have the basic VBA it would just need modifying to suit your requirement. Once you have the bookmarks set up and named and list them for me with the Table field name I can do the VBA.
 

karlhaywood

Thread Starter
Account Closed
Joined
Jan 17, 2010
Messages
680
Hi OBP,

Here is the bookmark names;

Add1
Area
City
FirstName
HeShe
LastName
PostCode
Prefix
Recommended

The name of the table in the database is "RecFriend"

Thank you.
 

OBP

Joined
Mar 8, 2005
Messages
19,895
OK I will post something tomorrow.
I will start slow and test each section before continuing.
 

OBP

Joined
Mar 8, 2005
Messages
19,895
Karl, I forgot to mention, the method that I have only uses the Word Doc as an Attachment, didn't you want a version that put it in the message Body?
 

karlhaywood

Thread Starter
Account Closed
Joined
Jan 17, 2010
Messages
680
This is not for an email, it is for letters we are sending out just a simple mail merge so i can pint off the letters.
 

OBP

Joined
Mar 8, 2005
Messages
19,895
OK, I have never used Word Mail Merge, from word or using VBA. I will have to see if I can find something to do so.
The code that I have would create Separate Word Docs for each person.
What does a mail merge do, create one word doc with "pages"?
 

OBP

Joined
Mar 8, 2005
Messages
19,895
I also found this simplified version

Function MergeIt()
Dim ObjWord As Word.Document
Set ObjWord = GetObject("C:\Documents and Settings\Administrator\Desktop\Database Project\Master Thank You Letter.doc", "Word.Document")
ObjWord.Application.Visible = True
ObjWord.MailMerge.OpenDataSource _
Name:="C:\Documents and Settings\Administrator\Desktop\Database Project\Database 1.mdb", _
LinkToSource:=True, Connection:="TABLE Main_Contracts_Database", _
SQLStatement:="SELECT * FROM [Main_Contracts_Database]"
ObjWord.MailMerge.Execute
End Function

Where the user has set the mail Merge up.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top