Automate Mail Merge From Command Button

Feb 7, 2005

Hey guys,

I have spent a while surfing around the site for the answer to this problem but to no avail.

I have a form with a command button which when pressed opens a Word Document. It's a mail merge template and I want to be able to automate the actual merge (merge to new a new Word document) as soon as the Word document opens.

Any help with this would be greatly appreciated. I am using the code below and cannot get the objWord.MailMerge.Execute line to work.

Rusty
:D

Private Sub cmdOK_Click()

On Error GoTo Err_cmdOK_Click

' Declare variables
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim varItem As Variant
Dim strCriteria As String
Dim strSQL As String

'Dim objWord As Word.Document

' Get the database and stored query
Set db = CurrentDb()
Set qdf = db.QueryDefs("qryMultiSelect")
' Loop through the selected items in the list box and build a text string
For Each varItem In Me!lstTrials.ItemsSelected
strCriteria = strCriteria & ",'" & Me!lstTrials.ItemData(varItem) & "'"
Next varItem
' Check that user selected something
If Len(strCriteria) = 0 Then
MsgBox "You did not select any Trials from the list." _
, vbExclamation, "Nothing to find"
Exit Sub
End If
' Remove the leading comma from the string
strCriteria = Right(strCriteria, Len(strCriteria) - 1)
' Build the new SQL statement incorporating the string
strSQL = "SELECT * FROM Trials " & _
"WHERE Trials.[Name of Trial] IN(" & strCriteria & ");"
' Apply the new SQL statement to the query
qdf.SQL = strSQL

' Open the MailMerge template
Call Shell("""C:Program FilesMicrosoft OfficeOfficeWINWORD.EXE"" ""O:ASWCSRecruitment dataCTU Cancer Trial Monthly UpdatesMonthlyUpdateTemplate.doc""", 1)

'objWord.MailMerge.Execute

' Empty the memory
Set db = Nothing
Set qdf = Nothing

Exit_cmdOK_Click:
Exit Sub

Err_cmdOK_Click:
Resume Exit_cmdOK_Click

End Sub

View Replies


ADVERTISEMENT

Automate Mail Merge From Access

Oct 11, 2006

Hi,

I have created a mail merge from a query in Access and it works fine if you run it from word but I would like to know how to automate the mail merge from Access using the Command button. Please can someone advise.

Thanks

Alex

View 5 Replies View Related

Automate Mail Merge Function From Access Database

Apr 23, 2013

I have a database, i need to automate mail merge function from access DB to insert selected records into the merge fields, i have tried everything i could and i have searched through out the web nothing really works for me.

View 1 Replies View Related

Can Put A Button On Form To Create Mail Merge Letter?

May 8, 2012

I have a database for my business, which lists clients details. Within this, I have a query that runs off receipts (one customer, many receipts), as I run a private school and people pay me monthly. I use this query to run off a Mail Merge letter within Word, but it's difficult, having to close the db and open a Word document and then relink it.

Is there any way that some coding could be used within the db so that I can add a button and just print out that record into a mail merge document?

View 1 Replies View Related

Reports :: Automate Printing From A Command Button With Selected Data From A Query?

Jul 15, 2013

How can I automate different printers for different reports on the same MS Access 2007 database, without having to select the printer each time?

There are two reports that are printed on the same database. Previously, I had automated form buttons to print the reports, without having to select the printer each time. This was about 8 years ago, but I don't remember how I did this. Also, I don't know SQL. Nothing against code, but I did not know how to program, and just MS Access 2007 access itself.

View 6 Replies View Related

Using Cc: With Mail Merge

Jul 20, 2005

When applicable, I have letters in Word already set up to show the cc: information at the bottom. However, Management needs a statement added to the bottom of the letters that ONLY show the cc:

I am having a slight problem trying to figure out how to make this statement show up only on certain letters.

Does anyone have any thoughts that could help me? I'd appreciate it very much.

View 2 Replies View Related

Mail Merge

Dec 28, 2005

I am totally new to Access and this is my first database.

I have a database for volunteers in which table A is basically a calendar and table B a list of volunteers with their details.

What I want to do is construct a report that will allow me to produce a mail merge letter such that:

1. One volunteer, with his/her information, is selected from table B and inserted into a mail merge letter. (The volunteer selected will change from letter to letter).

2 Certain days are selected from table A and added to the mail merge letter. This information will be the same in all letter.

I have posted a separate thread asking how I can make the selection of days in (2) above so you can assume that I know how to make the selection within table B.

How do I proceed?

If anyone knows a good example of this type of report then i will be extremely grateful.

View 3 Replies View Related

Mail Merge

Jan 23, 2006

I have a table that has, among others, Address1, Address2 and Address3. If Address2 andor Address3 are empty for a particular record, I get blank lines in the Word doc. How do I prevent these blank lines?

View 2 Replies View Related

Mail Merge

Apr 12, 2006

Hi, i have set up a mail merge between a query and a word document. My system is a system that processes transactions from an online cd shop. I have made it so that each cd that is bought by each customer is a different transaction in a transaction table, and each transaction is given an order number to group them. How do i get the mail merge to show all the transactions in an order on the invoice in my word doc because at the moment, even if i add two of the title name fields, they both show the same transaction.

View 4 Replies View Related

Mail Merge

Apr 2, 2007

Anyone have a good online resource for generating a single thank you letter, eg. by way of a mail merge using MS Access 2003 with Word 2003? I know you need to write a form letter first with various fields that conincide with fields in Access. I have done this many times with large mailings but need to know how to write individual letters for thank yous, invites, etc.

Thanks in advance

View 4 Replies View Related

Mail Merge Help!!

Feb 15, 2007

Hi,

I am editing the design of a census, and I would like to be able to mail merge form the query directly to a new document in microsoft word...so you can create the document and then merge to it, is this possible using a macro or VBA? I can't work out how to do it!! The query name is "List of Families" and I want to merge to a blank document, so I can create a different document everytime...as the letters aren't circulars!

Chris

View 1 Replies View Related

Mail Merge - Please Help!

Oct 20, 2004

I just finished creating an access file. Here are the contents:

TABLE Customers - Includes email, contact name, company name, address, zip, city, etc.
TABLE Materials - Includes company name and material. Each record is listed as a company with a material requested. Companies are listed multiple times, as they are unique records because the materials are different.

I have Company name set up as the primary key, and it sets the relationship between the two tables

I have a Report fully working. The first page is a letter with the customers' mailing info at the top.
The second page is a list of all the materials this company ordered for the 2004 year.

The report pulls from a QUERY that comes from the customers table and the materials table.

This report is hundreds of pages long, as we have multiple customers who order many materials each.

My question is "How do I mail merge this report out to the customer?" I do not want to send each customer the whole 500 page report, but only their specific record that they should receive.

I do not care if I have to merge with Word, Outlook, etc. I just dont want to have to send these out individually.

I hope that makes some sense.

PLEASE HELP!

-Preston

View 3 Replies View Related

Using Cc: With Mail Merge

Jul 20, 2005

When applicable, I have letters in Word already set up to show the cc: information at the bottom. However, Management needs a statement added to the bottom of the letters that ONLY show the cc:

I am having a slight problem trying to figure out how to make this statement show up only on certain letters.

Does anyone have any thoughts that could help me? I'd appreciate it very much.

View 6 Replies View Related

Mail Merge

Jan 17, 2008

Im after a bit of advice really. Im looking at building a mail merge facility, i already have one example where you have to select the letter you want to merge the data to.

The problem i have with this at the moment is i have allot of letters that are all basically very similar and the user might pic the wrong one, each letter is slight different and runs by a contract name.

Is there a way that the user can just select the type of letter they want, then select teh contract and then when they click the mail merge button access will know which letter to open.

Just looking for possible ways or examples.

Thanks

View 5 Replies View Related

Mail Merge Question...

Jul 1, 2005

I'd like to set up a mail merge that pulls information from individual records. For example... If I want to do a pre-formated Fax Cover Sheet in Word, and fill the information in with the mail merge.

I don't want this to pull information from all of the records. I want to choose which record to pull the information from. First of all, can this be done? If so, can someone help me out with this? I have no idea where to even begin with this one. I have several mail merge documents set up right now that pull information from queries, but this is something that I'd like to do that is completely different.

Thanks in advance for any help that you can give.

View 3 Replies View Related

Mail Merge Questions

Aug 31, 2005

What is the advantage of using mail merge?
It has been suggested to me that i use mail merge in the current application that im building. This is mainly because my client needs to send a lot of custom letters that will be different each time one is sent.
From what i know about mail merge you can only display information in a document in a flat format ie u couldnt have customer details at the top and then a table of all the orders/ transactions they have carried out below? is this correct?

View 1 Replies View Related

Mail Merge And Access

Dec 7, 2005

Hi, could anyone teach me how to do this? Thanks in advance!

Here is the result of a query I have:

PersonEmail ProductAmountCategory
AA@hotmail.comApple10Fruit
AA@hotmail.comOrange20Fruit
AA@hotmail.comPen30Office
BB@hotmail.comApple15Fruit
BB@hotmail.comOrange25Fruit
BB@hotmail.comPen35Office
CC@hotmail.comApple18Fruit
CC@hotmail.comOrange28Fruit
CC@hotmail.comPen38Office

What I need to do is the develop a report, in a format like:

Person:A

Category
FruitAmountOfficeAmount
Apple10Pen30
Orange20
Total30Total30




Do this for A,B,and C and send the individual report in via email to them. To me it looks like a mail merge, but I don't know how to manipulate the data and put it into the layout. My real data has a lot of data, about 100 person, and about 60 product that falls into two categories. Is there anyway easy and fast way to do this? Please help! Thank you very much!

View 2 Replies View Related

More Mail Merge Issues

Sep 13, 2006

The folks here have been a huge help to me as overseer of a database structure.

I wrote earlier about name and address databases I am using. immediately after entereing one new sets of client data, I will need to send to a letter by Word Mail Merge. I want to automate this with a button in the data entry form to be pushed when data entry is done. In other words, rather than having Word pull data from Access, I want Access to push data upon hitting the button, into a Word document If I could automate a printer to this, it would further save me steps to get the ultimate letter out ( two letters, of which one is chosen per client).

I hope first of all that this makes some sense. Then I hope one of you Access gods can help me as my brain is wisted by all this thinking and trying...

Thank you again.

View 1 Replies View Related

Mail Merge And Queries

Feb 22, 2008

I have a database with lots of names and addresses. For the first time I am trying to set up a mail merge to do a mail shot, my problem is that I can get the mail merge wizard to work fine with the underlying address table but if I create a query to do selective mailings then mail merge comes up with nothing. The query does work and produces the required list of addresses but when I run it through the wizard it doesn't seem to be able to see anything. Any suggestions? I assume that it should work with queries..

thanks

Dennis

View 1 Replies View Related

Word Mail Merge

Jul 8, 2005

I wonder if there is a way to link two tables or queries to a word doc for mail merge. I have an investigative memo and many findings associated with it. They all in Access for record keeping. Now I want to merge the main memo with all findings into a word document. The trick part is that the memo is also different so I cannot have a uniformed letter pre-defined in word. The content of memo is coming from Access too. I don't know if there is a way to do it or simply have two independent mail merges and combine two words doc in one (how?, hate to copy and paste).

Suggestions are appreciated.

Good day and night.

View 1 Replies View Related

Mail Merge Database

Sep 24, 2004

Can some on explain to me what I need to install and how to send a personalized mail merge from Access. I would like to use the names and email addresses from my database to send individual emails to everyone in it. Where do I find the proper add on? Thanks alot. Alex

View 3 Replies View Related

Mail Merge Sort Tab Not Available-Why???

Sep 25, 2004

i've searched the whole friggin net and i can't find an answer to this so if anyone knows please advise.

when you use an access database query as your data source in a MS Word mail merge. then, you go to queries. here there are two tabs: Filter and Sort.
here is my problem...why can't i sort??? the filter tab is functional but the sort tab is grayed out and unusable. i just can't figure out why!

thanks in advance!

View 2 Replies View Related

Access Mail Merge

Nov 19, 2004

I am using a query for a word mail merge and would like to maintain the formating from Access into Word. Is this possible and if so how. If not, anyone have a clue how to do it in Word... I am importing the date and would like it to be long version (Friday, November 19, 2004) and it's giving me the short version (11/19/04),

Thanks and have a great weekend!

View 2 Replies View Related

Mail Merge Macro

Feb 20, 2006

I am trying to create a mail merge macro that will automatically run when I open up my main document. I am using the RunApp command in Access to open up the main document. This is the code that runs the mail merge and it works fine when I go into Macros and run it. I just want it to run on its own. I know to get it to run on its own you have to use the AutoExec but I just can't figure it out.
Sub MailMerge()
'
' MailMerge Macro
' Macro recorded 2/20/2006 by melissa
'
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
End Sub

Any help would be great!

View 2 Replies View Related

Mail Merge Fiasco (OMG)

Aug 22, 2006

Hello Forum!

I heard this was the greatest help forum on the web so I decided to post here asking for help for a cause that seem helpless.

Here is my current predicatament:

I have a table that I would like to send through email to a specific person. I would like to send the email not as an attachment but as a regular email. I know I can create tables in microsoft access but by any chance is there a way to have an Outlook/Access Message Template, which takes the information from the table and sends the information to the specific person?

View 6 Replies View Related

Mail Merge - Access

Jul 25, 2007

I am wanting to create letters in word to go out to trainees which lists the courses they are booked on. I have successfully created a query which has a parameter under the 'Trainee ID' field, where I put in the trainee ID number and the query pulls out the courses that particular trainee is on. However, when I try to mail merge this into word, it works well BUT...insists on creating a new document/letter for each course the person is booked on.

What I wanted was for it to list the courses below the trainee name but can't for the life of me get it to do this

Anyone got any ideas ? I would appreciate any help with this

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved