Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem using MailMerge with a Word template

Status
Not open for further replies.

tgharris

Technical User
Jan 25, 2000
24
US
I am trying to produce Project Estimates by merging data from an Access select query (EstimateFillQuery, filtered by ProjectID using a SQL statement) into a document defined by a Word Template (path and filename defined by strTemplate). This is the code I have assembled so far: (objWord is a Word.Application object)<br>
<br>
Set objDocs = objWord.Documents<br>
objDocs.Add strWDTemplate<br>
<br>
'Activate MailMerge method, setting the data source<br>
'to EstimateFillQuery in this Database, with a SQL statement<br>
'to filter for current ProjectID.<br>
objDocs.MailMerge.OpenDataSource _<br>
Name:=dbs.Name, _<br>
LinkToSource:=True, _<br>
Connection:=&quot;QUERY EstimateFillQuery&quot;, _<br>
SQLStatement:=&quot;SELECT * FROM EstimateFillQuery&quot; _<br>
& &quot;WHERE [ProjectID] = &quot; & intProjectID & &quot;;&quot;<br>
<br>
'Run the mail merge<br>
objDocs.MailMerge.Execute<br>
<br>
However, running this code produces a Error #438--'Object Doesn't Support This Property or Method.&quot; I have traced the bug to this code sample. Could anybody suggest what I am doing wrong?
 
Yeah how complicated is your WORD document.<br>
It will be much faster to leave Word out of the picture.<br>
First of all every time you do something, Word has to load.<br>
Then it has to link back to Access.<br>
If you have a Screaming PIII with 128 Meg of RAM then it will be fast.<br>
Create an Access report that looks like your WORD doc.<br>
It can be done.<br>
<br>
But if you must use Word I did this way <br>
Use the Shell Statement instead.<br>
Your Word Doc can look at a Query if you must filter data out. I don't think it can look at a recordset the way you have it.<br>
Create a query using your SQL statement then save it.<br>
Open Word and mail merge it to the query. I've done it that way for years without problems.<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top