F
fmackay
Hi,
I am trying to fill fields on a Word form from an Access db - I found
this page: http://msdn2.microsoft.com/en-us/library/aa140082(office.
10).aspx
and used this code - successfully. But I have now moved onto a machine
with slightly newer versions of Access and VB, and now get error 91 -
object variable or with block variable not set at the line
Set doc = .Documents.Open(DOC_PATH & DOC_NAME, , True)
The machine where the code worked has Access 2002 SP2 and VB 6.3.8863,
the one I'm using now where the code breaks has Access 2002 SP3 and VB
6.4.8869; they probably have slightly different versions of Word, too,
but both Word 10.
The relevant code is:
Const DOC_PATH As String = "<path>"
Const DOC_NAME As String = "<filename>"
Dim appWord As Word.Application
Dim doc As Word.Document
Dim rst As ADODB.Recordset
On Error Resume Next
Set appWord = GetObject(, "Word.application")
If Err = 429 Then
Set appWord = New Word.Application
Err = 0
End If
With appWord
On Error GoTo ErrorHandler
Set doc = .Documents.Open(DOC_PATH & DOC_NAME, , True)
Set rst = New ADODB.Recordset
Any ideas?
Many thanks,
Finlay Mackay
I am trying to fill fields on a Word form from an Access db - I found
this page: http://msdn2.microsoft.com/en-us/library/aa140082(office.
10).aspx
and used this code - successfully. But I have now moved onto a machine
with slightly newer versions of Access and VB, and now get error 91 -
object variable or with block variable not set at the line
Set doc = .Documents.Open(DOC_PATH & DOC_NAME, , True)
The machine where the code worked has Access 2002 SP2 and VB 6.3.8863,
the one I'm using now where the code breaks has Access 2002 SP3 and VB
6.4.8869; they probably have slightly different versions of Word, too,
but both Word 10.
The relevant code is:
Const DOC_PATH As String = "<path>"
Const DOC_NAME As String = "<filename>"
Dim appWord As Word.Application
Dim doc As Word.Document
Dim rst As ADODB.Recordset
On Error Resume Next
Set appWord = GetObject(, "Word.application")
If Err = 429 Then
Set appWord = New Word.Application
Err = 0
End If
With appWord
On Error GoTo ErrorHandler
Set doc = .Documents.Open(DOC_PATH & DOC_NAME, , True)
Set rst = New ADODB.Recordset
Any ideas?
Many thanks,
Finlay Mackay