P
pman78x
Guest
I am trying to export data from MS Access (2003) to MS Excel (2003). For some reason this works perfectly in the English version of MS Office 2003, but not in the Ducth version of Office 2003.
I get the following error message when the export routine gets to the CopyFromRecordSet statement: Run time error 430 Class does not support automation . or does not support expected interface.
Van anybody help me?
Part of the code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim qd As QueryDef
Dim objXL As Object
Dim objWkb As Object
Dim objSht As Object
Dim intMaxRow As Integer
Set db = CurrentDb()
Set qd = db.QueryDefs("qry_Matrix")
Set rs = qd.OpenRecordset
Const Template = "Matrix.xlt"
Const StartRow = 8
If rs.RecordCount > 0 Then
rs.MoveLast: rs.MoveFirst
intMaxRow = rs.RecordCount
intMaxCol = rs.Fields.Count
Set objXL = CreateObject("Excel.Application")
With objXL
.Visible = True
Set objWkb = .Workbooks.Open(DbaseDir$ & Template)
Set objSht = objWkb.Worksheets("Matrix")
objSht.Name = "Matrix"
With objSht
.Range(.Cells(StartRow, 2), .Cells(StartRow + intMaxRow, 2)) _
.CopyFromRecordset rs
End With
End If
rs.Close
qd.Close
db.Close
I get the following error message when the export routine gets to the CopyFromRecordSet statement: Run time error 430 Class does not support automation . or does not support expected interface.
Van anybody help me?
Part of the code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim qd As QueryDef
Dim objXL As Object
Dim objWkb As Object
Dim objSht As Object
Dim intMaxRow As Integer
Set db = CurrentDb()
Set qd = db.QueryDefs("qry_Matrix")
Set rs = qd.OpenRecordset
Const Template = "Matrix.xlt"
Const StartRow = 8
If rs.RecordCount > 0 Then
rs.MoveLast: rs.MoveFirst
intMaxRow = rs.RecordCount
intMaxCol = rs.Fields.Count
Set objXL = CreateObject("Excel.Application")
With objXL
.Visible = True
Set objWkb = .Workbooks.Open(DbaseDir$ & Template)
Set objSht = objWkb.Worksheets("Matrix")
objSht.Name = "Matrix"
With objSht
.Range(.Cells(StartRow, 2), .Cells(StartRow + intMaxRow, 2)) _
.CopyFromRecordset rs
End With
End If
rs.Close
qd.Close
db.Close