Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / July 2006

Tip: Looking for answers? Try searching our database.

Entering parameter value in a mail merge

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JimAA - 19 Jul 2006 16:29 GMT
I have a Word template that uses an Access query with a parameter.  When I
open the template to create a new document I get a dialog box that asks for
the parameter data. After entering the data I get the same dialog box asking
for the same parameter data.  I'm assuming that I get a dialog box when the
template is opened and when the new document is opened.
Is there a way to avoid having to enter the same parameter data twice?
Thanks.
Peter Jamieson - 19 Jul 2006 18:35 GMT
Yes, this problem seems to occur in Word 2002 and later. I think the only
solution is to change the template so that it is not attached to the data
source, and use an AutoNew macro to open the data source when the new
document based on the template is created.

e.g. something like

Sub AutoNew()

Dim strPathName As String
Dim strConnect As String
Dim strQuery As String

' Put the pathname of your Access .mdb
strpathName = "c:\mydbs\mydb.mdb"

' Construct the Connect string

strConnect = "QUERY myquery"

' Construct the Query - you may also need WHERE and ORDER BY
' clauses for filtering and sorting

strQuery = _
 "SELECT * FROM `myquery`"

' The following should be enough in Word 2003
' If you do not need WHERE clauses etc. you
' can delete the SQLStatement line

 ActiveDocument.MailMerge.OpenDataSource _
   Name:=strPathName, _
   Connection:=strConnect, _
   SQLStatement:=strQuery, _
   Subtype:=wdMergeSubTypeWord2000

' Set the merge type you want
 ActiveDocument.MailMerge.MainDocumentType = wdFormLetters

' optionally set the destination you want
 ActiveDocument.MailMerge.Destination = wdSendToNewDocument

End Sub

Peter Jamieson

>I have a Word template that uses an Access query with a parameter.  When I
> open the template to create a new document I get a dialog box that asks
[quoted text clipped - 6 lines]
> Is there a way to avoid having to enter the same parameter data twice?
> Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.