I had this working the other day and now it just wont work right.
I have to merge a few fields from a form that has data entry in it. Only a few of the fields get merged
i use a button to save the record and open the Merge Form and then use a query to give me just those fields with =Forms!QrySIDRecord!ValidationNumber in the criteria of the Unique ID of the query. That returns the current record on the Merge Form. And then word opens the template but wont merge and stops at the OpenDataSource if I change anything then the QrySIDRecord doesnt work and I cant return the current record to the form.
Does anyone have any ideas?
Dim objWord As Word.Application
Dim doc As Word.Document
Set objWord = CreateObject("word.application") 'Create an instance of Word
objWord.Visible = True 'Make sure you can see it!!
objWord.WindowState = wdWindowStateMaximize 'Maximize it, otherwise is always about 1/4 of screen
'Open a document based on a template for merging
objWord.Application.Documents.Add Template:="C:\Documents and Settings\XXXX.XXX-XX\Desktop\RecordVrs2_03122003.dot", NewTemplate:=False
'Store name of document for later use
varDocName = objWord.ActiveDocument.Name
Name:="C:\Documents and Settings\XXXXX.XXX-XXX\Desktop\QID.mdb", _
Connection:="QUERY QrySIDRecord", _
SQLStatement:="Select * from [QrySIDRecord]"
If Err.Number = 94 Then
objWord.Selection.Text = ""
The error is this line: objWord.ActiveDocument.MailMerge.OpenDataSource
and the error message is this: Run-Time error '-2147417851 (80010105)'
The server threw an exception