Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export all tables from an Access Database into Excel - A sheet for each table

I have an Access database with ~30 tables.

How can I export all 30 tables into separate sheets in an Excel workbook?

I'm hoping to find some VBA/VBS code which I can run from within Access to accomplish this task.

Any ideas?

like image 511
Albert Avatar asked Oct 27 '10 19:10

Albert


People also ask

How do I export multiple tables from Access to Excel?

On the External Data tab, in the Export group, click Excel. In the Export - Excel Spreadsheet dialog box, review the suggested file name for the Excel workbook (Access uses the name of the source object). If you want, you can modify the file name. In the File Format box, select the file format that you want.


1 Answers

You should be able to do something like this:

Dim tbl as Tabledef
For Each tbl in Currentdb.TableDefs
  DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, tbl.name, "PathName.xls", True, tbl.name
Next

The second tbl.name is the worksheet name.

like image 74
BenV Avatar answered Sep 17 '22 20:09

BenV