我在论坛上看到一个将数据库中的所有表导出成EXCEL文件的范例,把它放到自己的数据库里就出现错误。现请教各位老师两个问题:
1.这段代码运行时,对数据库中的表是否有什么特殊的规定。
2.请各位老师对这段代码中的红色语句给予解释。
Dim wk1 As Workspace
Dim db1 As Database
Dim que1 As QueryDef
Dim stDocName As String
Dim stOutputFile As String
Set wk1 = DBEngine.Workspaces(0)
Set db1 = wk1.Databases(0)
For Each que1 In db1.QueryDefs
stDocName = que1.Name
stOutputFile = CurrentProject.Path & "\data\" & que1.Name & ".xls"
DoCmd.OutputTo acOutputQuery, stDocName, acFormatXLS, stOutputFile, False
Next
db1.Close
MsgBox "导出查询成功!" & Chr(13) & "共导出" & db1.QueryDefs.Count & "个查询到:" & CurrentProject.Path & "\data\" & "文件夹"
[此贴子已经被作者于2006-7-19 17:47:40编辑过]
|