0

我尝试了几种不同的方法,但在第一种方法之后它一直停止。我尝试添加其他表单,表单 1 在打开时运行一个,然后表单 1 打开运行一个导出等的表单 2,但这不起作用。我尝试暂停do while not isloaded(next form)等,但没有奏效。

Option Compare Database
Private Sub Form_Load()
On Error GoTo Err_Form_Load

'I tried 9
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
"AllActiveABC", _
"Y:\Projects\Protocol Folders\AllActiveABC.xls", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
"All-ActiveABC", _
"Y:\Projects\Protocol Folders\AllFilteredABC.xls", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
"All-ActiveABC", _
"Y:\Projects\Protocol Folders\AllFilteredABC.xls", True

'I tried 12 and 12XML
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12xlm, _
"AllActiveABC", _
"Y:\Projects\Protocol Folders\AllActiveABC.xls", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12xlm, _
"AllFilteredABC", _
"Y:\Projects\Protocol Folders\AllFilteredABC.xls", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12xlm, _
"AllActiveABC", _
"Y:\Projects\Protocol Folders\AllActiveABC.xls", True

'I tried it as a function
'see function below the three exports

Call exportData("All-FilteredABC", _
"Y:\Projects\Folders\All-FilteredABC.xlsx")
Call exportData("AllActiveABC", _
"Y:\Projects\Folders\AllActiveABC.xlsx")
Call exportData("AllABC", _
"Y:\Projects\Folders\AllABC.xlsx")


Function exportData(queryName As String, strSaveFileName As String)

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, queryName, strSaveFileName, True 

End Function

没运气。我对我尝试过的所有事情以及我喜欢的不同结果感到非常困惑,在现有工作簿中创建了一个新的空白表,但最后有一个 _1,在一次导出后停止,将它们全部导出,但全部为空白.

4

1 回答 1

0

尝试在每个 DoCmd 之后输入命令 DoEvents。让一切都赶上

IE

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _ "AllActiveABC", _ "Y:\Projects\Protocol Folders\AllActiveABC.xls", True

做事件

于 2012-11-17T03:23:23.127 回答