Private Sub cmdexcel_Click()
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object


Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add

Dim DataArray(1 To 500, 1 To 5) As Variant

Dim r As Integer
Dim NumberOfRows As Integer
NumberOfRows = Adodc1.Recordset.RecordCount
Adodc1.Recordset.MoveFirst

For r = 1 To NumberOfRows
DataArray(r, 1) = Adodc1.Recordset.Fields("name")
DataArray(r, 2) = Adodc1.Recordset.Fields("Date")
DataArray(r, 3) = Adodc1.Recordset.Fields("address")
DataArray(r, 4) = Adodc1.Recordset.Fields("Work")
DataArray(r, 5) = Adodc1.Recordset.Fields("Details")

Adodc1.Recordset.MoveNext
Next
Set oSheet = oBook.Worksheets(1)
oSheet.Range("A1:E1").Font.Bold = True


oSheet.Range("A1 :E1").Value = Array("ID", "Date", "address", "Work", "Details")



oSheet.Range("A2").Resize(NumberOfRows, 5).Value = DataArray

oBook.SaveAs "C:\Report.xls"
oExcel.Quit
Adodc1.Recordset.MoveFirst
MsgBox "Report File Saved", 64, "Info"

End Sub 