Mail Merge HELP

  • Thread starter Thread starter Rodger
  • Start date Start date
R

Rodger

Hello all,

I am trying to create a mail merge. The data is in a csv file and the
Word Document is a Template.

Here is part of my code

'CREATE WORD DOCUMENTS

myTemplatePath = "R:\Application Documents"
myTemplateName = myTemplatePath & "\504 CDC Checklist for
Submitting loan.dot"

'504 CDC Checklist for Submitting loan
myDocName = myDocumentPath & "\" & myFolderName & "\504 CDC
Checklist for Submitting loan.doc"
myDataSource = myDocumentPath & "\" & myFolderName &
"\tmp_CheckLists.csv"

Set oApp = GetObject(myTemplateName, "Word.Document")
'oApp.Application.Visible = True
oApp.MailMerge.OpenDataSource Name:=myDataSource,
LinktoSource:=True, AddToRecentFiles:=False
oApp.MailMerge.Destination = wdSendToNewDocument
oApp.MailMerge.SuppressBlankLines = True
oApp.MailMerge.Execute

oApp.Application.Documents(1).SaveAs (myDocName)

If myView = 2 Then
oApp.Application.Visible = True
oApp.Close SaveChanges:=wdDoSaveChanges
Else
oApp.Application.ActiveDocument.PrintOut
oApp.Application.Documents(1).Close
End If

Set oApp = Nothing

OK here is the issue.

If I run the code twice I still have WINWORD.exe open. I need to be
able to run this from multiple PCs. I thought that I had this working
but it seems that I don't

I am sure I am missing somthing simple.

The csv file if being created and the Word Template is there. When I
run the code for the first time all works great but then if I want to
print the document I get an error that the file is open. Only because
it never close properly. How can I make sure that WINWORD.EXE is
closed?

TIA,
Rodger
 
Do you have the data in ms-access already?

I have a nice working sample that does a merge of the current record to
word.

The sample I have can be found here:
http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html

What is nice/interesting about my sample is that is specially designed to
enable ANY form with ONE LINE of code....

Thus, each time you build a new form, you can word merge enable it with
great ease.

Make sure you read the instructions from above, and you should eventually
get to the follwoing page
http://www.members.shaw.ca/AlbertKallal/wordmerge/page2.html


Note that the merge can also use a query, and thus you don't have to merge
just "one" record..

After the merge occurs, you get a plain document WITHOUT any merge fields,
and this allows the end user to save, edit, or even email the document
(since the merge fields are gone after the merge occurs).

So, if you have the data in ms-access already, then the above might be of
help to you....
 
Hi Albert,

I tried downloading your sample to try it and I create a word doc on my
desktop called Doc3. It show in the Template window and I highlighted and
clicked ok to merge and the title of the document change to Forms Letter1 but
the document is blank whether I merge one record or both. Am I doing
something wrong? It looks like a nice piece and can come in handy and I am
sure I can use it, just need to understand how it works. :o)

Thanks!!!
 
Stockwell43 said:
Hi Albert,

I tried downloading your sample to try it and I create a word doc on my
desktop called Doc3. It show in the Template window and I highlighted and
clicked ok to merge and the title of the document change to Forms Letter1
but
the document is blank whether I merge one record or both. Am I doing
something wrong? It looks like a nice piece and can come in handy and I am
sure I can use it, just need to understand how it works. :o)

It shows blank unless you actually drop in a field and place it into the
document.....

it is a word thing.....
 
Back
Top