'Create a new project called ActiveX DLL project DbToExcel' Engineering -> references cited Microsoft ActiveX Data Objects 2.6 Library 'Microsoft Excel 9.0 Objects Library Option Explicit Private Mcnnquery As ADODB.Connection' defines ADO Connection object Private Mrsquery As ADODB.Recordset ' ADO record object defined Dim objExcel As Excel.Application 'custom Excel objects Dim ObjWorkBook As Excel.Workbook' defined workbook Dim objSheet As Excel.Worksheet 'defined worksheet Dim objRange As Excel.Range' define user worksheet range Private Property Set Connquery (ByVal Conn As ADODB.Connection) Set Mcnnquery = ConnEnd Property Private Property Get Connquery () As ADODB.Connection Set Connquery = McnnqueryEnd Property Private Property Set Rsquery (ByVal Rs As ADODB.Recordset) Set Mrsquery = RsEnd Property Private Property Get Rsquery () As ADODB.Recordset set Rsquery = MrsqueryEnd property 'properties methods There are three parameters' strcnn connection object 'strrs data set object' strpath EXCEL file Public Sub DbtoExcel (strcnn As ADODB.Connection, Strrs As ADODB.Recordset, strpath As String) DIM I as INTEGER, J AS Integeron Error Goto Err Set Connq uery = Strcnn 'provided cnnquery property Set Rsquery = Strrs' provided rsquery property Set ObjExcel = New Excel.Application Set ObjWorkBook = ObjExcel.Workbooks.Open (Strpath) 'open EXCEL file Set ObjSheet = ObjWorkBook.ActiveSheet Set ObjRange = ObjSheet.UsedRange' User Worksheet range for i = 1 to rsquery.fields.count objrange.cells (1, i) = rsquery.fields (i - 1) .Name Next I for j = 1 to rsquery.recordcount for i = 0 To RSQuery.fields.count - 1 Objrange.cells (j 1, i 1) = rsquery.fields (i) .Value Next i rsquery.movenext Next J Objexcel.quit set objWorkbook =