Mail Merge - Code to complete merge

C

Craig Ferrier

I use an Access database and modules to prepare a mail merge.

It opens word and shows the document with the field codes and doesn't
actually finish the merge (purposely). When the word document opens I would
like it to show the results of the merge data and then create a text box
with "are you ready to finish the merge" Y/N option, and then complete the
merge.

How can this be done.

Craig
 
C

Craig Ferrier

Purpose: the mail merge has been set up as an email merge. I want to view
the document before it sends it.

Craig
 
D

Doug Robbins - Word MVP

Show us your code.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

Jezebel

You can use the 'Merge to new document' option (on the MailMerge toolbar) to
get a preview.

Or disable your internet connection, run the merge, and look at the results
in the Outlook Outbox. If you're happy, re-enable your connection.
 
C

Craig

Code is as follows: I am using a word merge that was created by someone
else but editing it to perform differently.

If strActiveDoc = "Invoice.doc" Then

WordDoc.MailMerge.OpenDataSource _
Name:=strDataDir & TextMerge, _
ConfirmConversions:=False, _
ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=0, _
Connection:="", SQLStatement:="", SQLStatement1:=""

With WordDoc.MailMerge
.ReadOnly = True
.Destination = 2 ' 0 = new doc 2=email
.MailAsAttachment = False
.MailAddressFieldName = "AdEmail"
.MailSubject = "Invoice " &
Forms!frmAdvertisers!subfrmAdvertisements!AdvertisementID
.SuppressBlankLines = True
With .datasource
.FirstRecord = 1
.LastRecord = 1
End With
'.Execute Pause:=False (This line i noted which seems to stop the
mail merge from executing)
End With

'WordDoc.Close (False)

wordApp.Visible = True
wordApp.Windows(wordApp.Windows.Count).Activate
If strOutDocName <> "" Then
wordApp.ActiveDocument.SaveAs strOutDocName
End If

AppActivate "Microsoft Word"
wordApp.Activate
wordApp.WindowState = 1


Thanks
Craig
 
C

Craig

I have found one part of the solution

WordDoc.MailMerge.ViewMailMergeFieldCodes = 0 (this switches from field
view to data view) -1 (field)

Craig
 

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