I researched the same issue. The solution posted by Gord gave me an XML interpretation error. Cosmichighway posted 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 was generating a unique filename per export, so I reverted to the original filename path once the process was complete. WorkHoursTransactions is a 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 came across this nice tip to use the immediate window to display the XML. If you have an export specification named 'Export-Table1', then you can paste this in the immediate window to view the XML:
? CurrentProject.ImportExportSpecifications.Item("Export-Table1").XML