CopyFromRecordSet gives 430 run-time error (1 Viewer)

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
 

PeterF

Registered User.
Local time
Today, 17:29
Joined
Jun 6, 2006
Messages
295
Try naming the the worksheet different, I believe "matrix" is a reserved word in the dutch version. What is the name of the function??
 
P

pman78x

Guest
I just mentioned 'Matrix' here to shorten the code.

The actual values are:
Const Template = "Function Task Matrix.xlt"
Set qd = db.QueryDefs("qry_Function_Task_Matrix_Crosstab_with_SODs")
Set objSht = objWkb.Worksheets("Function-Task Matrix")
objSht.Name = "Task-Function Matrix"

Appologies for the confusion.

The code is run on the on click event of a command button. It starts en ends with:
Private Sub cmdFunctionTaskExcelwithSODs_Click()
End Sub
 

Users who are viewing this thread

Top Bottom