先建好一个电子表格文件,如果需要两张表,请在Sheet1和Sheet2的第一行输入字段名,然后用类似下面代码导出:
Dim dbs As DAO.Database
Set dbs=CurrentDb
dbs.Execute "INSERT INTO [Excel 8.0;DATABASE=E:\导出文件夹\电子表格.xls].[Sheet1$] SELECT TOP 65535 * FROM 表名"
dbs.Execute "INSERT INTO [Excel 8.0;DATABASE=E:\导出文件夹\电子表格.xls].[Sheet2$] SELECT * FROM 表名 Where ID Not In (SELECT TOP 65535 ID FROM 表名)