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 Dutch 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.
Can anybody help me?
The code is run on the on click event of a command button. Part of the code:
Private Sub cmdFunctionTaskExcelwithSODs_Click()
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_Function_Task_Matrix_Crosstab_with_SODs")
Set rs = qd.OpenRecordset
Const Template = "Function Task 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("Function-Task Matrix")
objSht.Name = "Task-Function Matrix"
With objSht
.Range(.Cells(StartRow, 2), .Cells(StartRow + intMaxRow, 2)) _
.CopyFromRecordset rs
End With
End If
rs.Close
qd.Close
db.Close
End sub
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.
Can anybody help me?
The code is run on the on click event of a command button. Part of the code:
Private Sub cmdFunctionTaskExcelwithSODs_Click()
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_Function_Task_Matrix_Crosstab_with_SODs")
Set rs = qd.OpenRecordset
Const Template = "Function Task 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("Function-Task Matrix")
objSht.Name = "Task-Function Matrix"
With objSht
.Range(.Cells(StartRow, 2), .Cells(StartRow + intMaxRow, 2)) _
.CopyFromRecordset rs
End With
End If
rs.Close
qd.Close
db.Close
End sub