ADO learning
Thanks so much for your help. I downloaded the help file and it was very helpful. My command button now does exactly what I want (exporting a range, w/o column headings). One minor detail....how do I set the coulmn widths for export? I need one field to be 8 chars, next 3, so on. I pasted my code from my command button below.
____________________________________________________
Private Sub Command117_Click()
On Error GoTo report_Err
'Create a Recordset from all the data in the INVWC7 table
Dim sRecon As String
Dim conn As New ADODB.Connection
Dim rs As ADODB.Recordset
sRecon = "N:\LOG PRO-ADV RECON\reconciliation.mdb"
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sRecon & ";"
conn.CursorLocation = adUseClient
Set rs = conn.Execute("INVWC7", , adCmdTable)
'Create a new workbook in Excel
Dim xlApp As Object
Dim xlBook As Object
Dim xlSheet As Object
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
'Transfer the data to Excel
xlSheet.Range("A1").CopyFromRecordset rs
'Save the Workbook and Quit Excel
xlBook.SaveAs "N:\LOG PRO-ADV RECON\advantage\INV280-B.xls"
xlApp.Quit
export_Exit:
MsgBox "Your INV280-B report has been saved to: N:\LOG PRO-ADV RECON\advantage\INV280-B.xls"
Exit Sub
report_Err:
MsgBox "Your report could not be exported. Be certain that you have no other instances of this file open."
Exit Sub
'Close the connection
rs.Close
conn.Close
End Sub
