Mail Merge for Access & Word

G

Guest

I have a database which I'm trying to merge 1 record on click command button
to a Word document.

I'm not sure on how to merge the data from access to the merge document and
also how to do the actual linking of the database and word file.

I have looked at Albert Kallal databases but still don’t understand this.

Help please

For info, I have got this far:

I have completed the letter in word but not done any mail merging

i have added a command button in Access and on click, i have the following:

Private Sub Completion_Letter_Click()

MergeSingleWord "H:\NNDR Reports\completion letter.doc", True

End Sub

The 'H:\NNDR Reports\completion letter.doc' is the file path and name.

What else do i do?
 
G

Guest

Have you 'told' the Word letter what part of your Access database to link to?
This can be a table or a query which contains all the fields you need in the
letter. You set the Data Source in the Word document - how to do this depends
on which version of Word you are using. Up to 2000 it will be on the Tools
menu, XP+ in the Mail Merge Task Pane.

Hope this helps

Sheila
 
A

Albert D. Kallal

MergeSingleWord "H:\NNDR Reports\completion letter.doc", True

the above will not work. This is because you CAN NOT specify the merge
document when you use

mergeSingleWord

If you want to "list" all of the documents, and selected a document, then
use:

MergeSingleWord "H:\NNDR Reports\ ", True

Are you assuming (or want) that the user cannot select which document to
use?

The first issue is that you need to create this template, and add the merge
fields.

I would try the above command first....

I would then choose your completion letter.doc...(use the "modify template"
button). You add the fields etc...

After you add the merge fields, you can save the document. You can then use
the merge button.

I would get the above working first.

If you plan is eventually to NOT prompt the user for a particular word
document, then
use:

MergeNoPrompts "completion letter.doc","H:\NNDR Reports\",True

Note how the above allows you to specify the merge document without the user
being prompted (hence NoPrompts).

You can also specify the output document name if you wish. And, you can
even have the document print if you don't want the user to edit the document
first.

So, using the MergeNoPompts will eliminate the "prompts" for what word
documents. However, you REALLY want to use MergeSingeWord, and then SELECTED
the document (use the "modify template option). You have FIRST MODIFY the
word document and add the merge fields. In fact, if there are no merge
fields in the document...my code fails....(something I plan to fix one day).

Additional options can be found here:
http://www.members.shaw.ca/AlbertKallal/wordmerge/page2.html

So, use the mergeSingleWord. Edit the document using that option (modify
template). Save the word document...get it working. Once you get it working,
and then to eliminate the prompts...change the code to MergeNoPrompts and
the you can hard-code (specify) the document name without the user having to
select from a list.
 
G

Guest

Fair enough Albert - is there a particular reason why this (looks very
complicated) method is better than just setting the Hyperlink To property to
the Word document?

Sheila
 
A

Albert D. Kallal

Sheila D said:
Fair enough Albert - is there a particular reason why this (looks very
complicated) method is better than just setting the Hyperlink To property
to
the Word document?

Sheila

Well, it is only one line of code. If you use Hyperlink, your users don't
get to select the document for the merge (but, you don't seen to need that
ability). Also, if you use hyperlink, then you don't have the ability to
merge the ONE record you are viewing. Hyperlink is not different then if
the user simply browsed to the word document, and clicked on it. If you just
click on the word document (or user hyperlink), then you don't have any
control over what records are to be send to the word document.

So, yes...if you just need to open the word document, then you don't need my
code (it is not worth the effort). However, to be able to place ONE LINE of
code behind a button and merge the current record, and select from a list of
templates, you can't beat one line of code!!!

Further, users can use the "add new template" button...and again all of the
merge fields etc are setup for you.

So, the usefulness of my example really depends on how skilled your users
are. With my example, they can create, or use merge templates, and do so
with less training. And, if you need to easily provide a merge the current
record you are viewing, one line of code is a nice solution.
 
G

Guest

Thanks Albert, that's very clear and I can see the benefit, will definitely
keep it in mind for the future

Sheila
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top