Export MSaccess table data into a XLS file using VB code.

Objectname – A string expression that is a valid name for the object type selected in the Object Type argument. To output the current active object then leave this argument blank.

Outputformat – Choose on of the following constants:
acFormatActiveXServer acFormatHTML acFormatIIS acFormatRTF acFormatTXT acFormatXLS
Leave the outputformat argument blank to select the output format at runtime.

Outputfile – The output file path as string. To enter the destination at runtime leave this argument blank. Objecttype – may be any of the following constants:

acOutputForm acOutputModule acOutputQuery acOutputReport

acOutputTable

Outputfile – The output file path as string. To enter the destination at runtime leave this argument blank.

Autostart – Use True (1) to start the appropriate Microsoft Windows�based application immediately, with the file specified by the outputfile argument loaded. Use False (0) if you don’t want to start the application. This argument is ignored for Microsoft Internet Information Server (.htx, .idc) files and Microsoft ActiveX Server (*.asp) files. False is the default value.

Templatefile – A string expression specifying the full path and name for a template(HTML, HTX, and ASP files)

Example :-
Dim strInputTableName As String
Dim strFilePath As String

strFilePath = “C:\Customers.xls” ‘Path to export to strInputTableName = “Customer” ‘Object Name i.e. Query Name, table name

DoCmd.OutputTo acOutputQuery, strInputTableName, acFormatXLS, strFilePath, True

Reference :-

http://msdn.microsoft.com/en-us/library/bb238050(v=office.12).aspx
http://www.blueclaw-db.com/docmd_outputto_example.htm

150 150 Burnignorance | Where Minds Meet And Sparks Fly!