merge field calculation error

billyr

Registered User.
Local time
Today, 11:33
Joined
May 25, 2003
Messages
123
Running the code below, I get an error in Word displayed on a blank document. (field calculation error in record 1) If I manually execute the merge in Word from the same query it works fine. Obviously there is something wrong with the code. The code is a slightly modified version of code I got from a knowledgebase article. The modification changes the module to a sub instead of a function and allows me to pass the document name to it.

Public Sub MergIt(docObj As String)
Dim objWord As Word.Document
Set objWord = GetObject(docObj, "Word.Document")
'make word visible
objWord.Application.Visible = True
'set data source
objWord.MailMerge.OpenDataSource NAME:="c:\Sales_dev\mysales.mdb", _
LinkToSource:=True, Connection:="QUERY mail_list", _
SQLStatement:="Select * from [mail_list]"
objWord.MailMerge.Execute
objWord.MailMerge.Destination = wdSendToNewDocument
End Sub
 
I have either solved it or worked around the real problem:
A: I'm now merging from a table;
B: I now open the document using the DOS name extension,".DOT".
This works great. I really don't what the real problem was.
 

Users who are viewing this thread

Back
Top Bottom