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:="QUERY EstimateFillQuery", _<br>
SQLStatement:="SELECT * FROM EstimateFillQuery" _<br>
& "WHERE [ProjectID] = " & intProjectID & ";"<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." I have traced the bug to this code sample. Could anybody suggest what I am doing wrong?
<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:="QUERY EstimateFillQuery", _<br>
SQLStatement:="SELECT * FROM EstimateFillQuery" _<br>
& "WHERE [ProjectID] = " & intProjectID & ";"<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." I have traced the bug to this code sample. Could anybody suggest what I am doing wrong?