我研究了同樣的問題。 Gord發佈的解決方案給了我一個XML解釋錯誤。 Cosmichighway發佈了這個解決方案:http://www.utteraccess.com/forum/index.php?showtopic=1981212。
此解決方案在Access 2010和Access 2013,也應該在Access 2007
With CurrentProject.ImportExportSpecifications("nameOfSpecification")
debug.print .XML
.XML = Replace(.XML, varSavedPathName, varNewPathName)
debug.print .XML
End With
我產生每出口一個唯一的文件名的工作,所以我恢復到原來的文件名路徑一旦這個過程完成。 WorkHoursTransactions是一個常量。例如:
CONST ConstExportSavedPathName="c:\temp\Name Of File To Use.xls"
tmpFileName = WorkHoursTransactions & ";" & Format(Now(), "YYYYMMDD-HHMMSS") & ".xls"
With CurrentProject.ImportExportSpecifications(WorkHoursTransactions)
.XML = Replace(.XML, ConstExportSavedPathName, tmpFileName)
'Debug.Print .XML
End With
DoCmd.OpenReport WorkHoursTransactions, acViewReport, , , acWindowNormal
DoCmd.RunSavedImportExport WorkHoursTransactions
' return to original filename
With CurrentProject.ImportExportSpecifications(WorkHoursTransactions)
.XML = Replace(.XML, tmpFileName, ConstExportSavedPathName)
'Debug.Print .XML
End With
我也遇到了這個不錯的提示,使用即時窗口來顯示XML。如果你有一個名爲「導出-表1」出口規範,那麼您可以在即時窗口中粘貼此查看XML:
? CurrentProject.ImportExportSpecifications.Item("Export-Table1").XML
一如既往地堅持和樂於助人Gord,謝謝! – pegicity
非常感謝Gord! – ArtiBucco
顯然這應該很好,並提供良好的背景信息,但我發現http://stackoverflow.com/a/14443025/6099655第二個子()更直接 – CWilson