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\" & "文件夹"
AutoStart Variant 型,可选。该参数为 True (-1) 可立刻启动适当的基于 Microsoft Windows 的应用程序,并加载由 OutputFile 参数指定的文件。如果不想启动该应用程序,可将该参数设为 False (0)。对于 Microsoft Internet Information Server (.htx、.idc)文件和 Microsoft ActiveX Server 文件 (*.asp),将忽略该参数。如果将该参数留空,就会采用默认值 (False)。