Mail Merge

P

Phil

I have a mail merge document called "Gift Aid letter.docx" (tried it as both
a docx and dotx) with graphics and wording in the header. The mail merge data
is in a csv file. The datafile is called "Gift Aid letter.888"
Mailmerge is being run through Access & VBA.

Here is the relevant code

Set WordDoc = wordApp.Documents.Open(strDocName)

strActiveDoc = wordApp.ActiveDocument.Name
'wordApp.Activate

If bolPrint = False Then
wordApp.Visible = True
wordApp.Activate
wordApp.WindowState = 0 'wdWindowStateRestore
End If

STOP 1
WordDoc.MailMerge.OpenDataSource _
Name:=strDataDir, _
ConfirmConversions:=False, _
ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _
PasswordDocument:="", ent:="", PasswordTemplate:="",
WritePasswordDocument:="", _ WritePasswordTemplate:="", Revert:=False,
Format:=wdOpenFormatDocument, _ Connection:="", SQLStatement:="",
SQLStatement1:=""

STOP 2
With WordDoc.MailMerge
.Destination = 0 ' 0 = new doc
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .datasource
.FirstRecord = 1
' .LastRecord = 1
End With
.Execute Pause:=False
STOP 3
End With

at STOP 1 I see the original letter with the name & address of the peson
printed on the previous run. Letter name is Gift Aid letter.docx at STOP 2I
see the original letter with the Merge field names showing. Letter name is
Gift Aid letter.docx at STOP 3 I see the merged letter with the new name &
address, but only the wording in the header. The graphics have disappeared.
This letter is called Form Letters1. The STOP2 letter is still visible.
Eventually Form Letters1 gets saved as "Test Mail Merge.docx"
When I open this, even the wording in the header has vanished. Only the
actual body wording is correct What am I doing wrong?

Thanks

Phil
 
S

Suzanne S. Barnhill

If this were a simple mail merge, I don't see why you would need VBA at all.
You create the mail merge main document, link it to the data source, and
then click Merge to New Document, after which you can edit, save, and/or
print the result.

But I get the idea you are actually trying to execute something more like
WordPerfect's keyboard merge process to create a single letter. If so, it
might be more satisfactory to use a UserForm to collect the name and address
information to be inserted in the form letter (or even just use MacroButton
NoMacro fields to type directly into).

If this is a situation where you are adding new records to a data source and
then creating a letter for each newly added one (as would be the case in a
situation of a growing mailing list), then you can open the mail merge main
document and use Select Recipients to check off just the records you want
included in the merge.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
P

Phil

If this were a simple mail merge, I don't see why you would need VBA at
all. You create the mail merge main document, link it to the data source,
and then click Merge to New Document, after which you can edit, save,
and/or print the result.

But I get the idea you are actually trying to execute something more like
WordPerfect's keyboard merge process to create a single letter. If so, it
might be more satisfactory to use a UserForm to collect the name and
address information to be inserted in the form letter (or even just use
MacroButton NoMacro fields to type directly into).

If this is a situation where you are adding new records to a data source
and then creating a letter for each newly added one (as would be the case
in a situation of a growing mailing list), then you can open the mail
merge main document and use Select Recipients to check off just the
records you want included in the merge.

Thanks for coming back so quickly, Suzanne

What I am trying to achieve is that I press a button on an Access form which
must automatically generate mailemege letters based on information within the
database, one of the parameters being that the DatePrinted is Null. The user
then confirms that the letters have printed out correctly, at which point the
database gets updated to set DatePrinted to Date() ie date the letter was
printed. All works perfectly other than the fact there are no headers on the
merged document and consequently the body of the letter has mooved up the
page.

Thanks

Phil
 

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