Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access data captured by word MailMerge and copying contents with VBA

Status
Not open for further replies.

JimWho

Vendor
Apr 2, 2002
16
0
0
CA
I have a mailmerge word document that when launched opens up and retrieves data from an MS Access query. The query has two parameters that must be completed, customer name and date. I then manually merge to a new document.

On the new document I have a Send Mail button which when launched asks me for the Customers name. I enter the Customer name select OK at which time the name is saved as part of the filename along with current date. Then the document is automatically sent out to a specified address as an email attachment. I then get a message box telling me the report was sent. I select OK and the word document closes back to the original merge doc. My questions are:

1. When the New word document is closed with code, is there a way to close the ms access database with code? I need to close it to launch the next new document which will have a different name and possibly different date. Currently I close the access database manually. If I don't do this and select Merge to New Document I get the same information in the new document as previously asked for. It does not ask for a new customer/date.

2. Also is there a way to capture the Customer Name and Date of the report using VBA after the mergefields are populated so that this information could be entered as part of the filename when being saved without manually populating a message box?

This is of course all within Word.

Appreciate any help I can get.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top