Exporting Access table data to Excel


I have a table in Access 2007 with 11,000 rows and about 20 columns. I want to create a form button that exports the table to an Excel sheet. The code need to be VBA.

Any Ideas?


Here's an example.

    DoCmd.TransferSpreadsheet acExport, _
                                acSpreadsheetTypeExcel8, _
                                "myQuery", _
                                "C:\myDir\myFile.xls", _

You probably need to make sure that your destination is clear of the output filer (myFile.xls).


From access you can also use the TransferSpreadsheet method.

By : AlexCuse

You're probably better off using the System.IO.DirectoryInfo class to interpret your relative path. You can then pick off folder or file names using its members:

DirectoryInfo di = new DirectoryInfo("images/gringo/");

This will be much safer than any regexps you could use.

This video can help you solving your question :)
By: admin