I investigated the same problem. The solution posted by Gord gave me an XML interpretation error. Cosmichighway published this solution: http://www.utteraccess.com/forum/index.php?showtopic=1981212 .
This solution works in Access 2010 and Access 2013, and should also work in Access 2007.
With CurrentProject.ImportExportSpecifications("nameOfSpecification") debug.print .XML .XML = Replace(.XML, varSavedPathName, varNewPathName) debug.print .XML End With
I created a unique file name for export, so after the process was completed, I returned the original path to the file name. WorkHoursTransactions is const. Example:
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
I also stumbled upon this good tip to use an immediate window to display XML. If you have an export specification with the name "Export-Table1", you can paste it in the next window to view the XML:
? CurrentProject.ImportExportSpecifications.Item("Export-Table1").XML
Albert
source share