Pages

Showing posts with label Export Table To Excel File. Show all posts
Showing posts with label Export Table To Excel File. Show all posts

Wednesday, December 28, 2011

Export Table To Excel File

IF you want to export the access table to excel spreadsheet.

Here is the code-

Sub export_access_table_to_excel()
DoCmd.SetWarnings (False)
Dim importtable As String, exportfile As String
' table name to be exported
importtable = "sales_detail"
' file name or spreadhseet name with extension
exportfile = "C:\Users\ashishkoul\Desktop\learn\sales_detail.xlsx"
' check if the any excel file aready exists with same name
If Dir(exportfile) <> "" Then
MsgBox "File already exists"
Exit Sub
End If
' export the table to workbook
DoCmd.TransferSpreadsheet acExport, , importtable, exportfile, True
DoCmd.SetWarnings (True)
End Sub


Download Access Database