View Single Post
  #1 (permalink)  
Old November 1st, 2004, 04:29 PM
clueless_may clueless_may is offline
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Class doesn't support automation error

Hi All,

I am trying to create an excel file(see below for my code) through access and I get an error saying Run-time error 430: Class doesnt support automation

Can someone please help!

Private Sub cmdGetReport_Click()

Dim adoConn As New ADODB.Connection
Dim adoRec As New ADODB.Recordset
Dim xlApp As Excel.Application
Dim strsql As String
Dim xlWB As Excel.Workbook
Dim strfilename As String
Dim i As Long

Set xlApp = New Excel.Application

adoConn.CommandTimeout = 0
adoConn.Open "DSN=mays"

strsql = "select * from dw.maysoon_proc_test"
adoRec.Open strsql, adoConn


xlApp.Workbooks.Add
Set xlWB = xlApp.ActiveWorkbook

For i = 0 To adoRec.Fields.Count - 1
    Cells(1, i + 1).Value = adoRec.Fields(i).Name
Next

xlWB.Sheets(1).Range("A2").CopyFromRecordset adoRec<----ERROR ON THIS LINE<-------------

strfilename = "C:\TESTING2.xls"
 If Len(Dir(strfilename)) Then
    Kill strfilename
 End If

adoConn.Close

End Sub