Code:
Private Sub btnExportToExcel_Click()
Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
Dim MyRecordset As New ADODB.Recordset
MyRecordset.ActiveConnection = cnn
Dim MySQL As String
MySQL = "SELECT XRayedConsignments.[dteEntryDateTime], XRayedConsignments.EntryTime, XRayedConsignments.AWBNumber, XRayedConsignments.Pieces, XRayedConsignments.Weight, XRayedConsignments.OpsIDNumber, XRayedConsignments.Mail, XRayedConsignments.Transhipment, XRayedConsignments.Iberia, XRayedConsignments.UnitedAirlines, XRayedConsignments.ELAL, XRayedConsignments.AirMauritus FROM XRayedConsignments"
MyRecordset.Open "Select * FROM XRayedConsignments"
Dim MySheetPath As String
MySheetPath = "E:\Worksheets\XRayedConsignments.xls"
Dim Xl As Excel.Application
Dim XlBook As Excel.Workbook
Dim XlSheet As Excel.Worksheet
Set Xl = NewExcel.Application
Set XlBook = Xl.Workbooks.Open(MySheetPath)
Xl.Visible = True
XlBook.Windows(1).Visible = True
Set XlSheet = XlBook.Worksheets(1)
XlSheet.Range("A4").CopyFromRecordset MyRecordset
MyRecordset.Close
Set cnn = Nothing
Set Xl = Nothing
Set XlBook = Nothing
Set XlSheet = Nothing
End Sub
Hope you can find something Bob