Link to home
Start Free TrialLog in
Avatar of marlind605
marlind605Flag for United States of America

asked on

Microsoft Access 2013 TransferSpreadsheet generates Excel but When it is opened Extension Not Valid Error

I am using the following code to export a query from Microsoft Access 2013
myfilename = "W:\AD_Reports\AnotherTest.xlsx"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryalltimerecordsbydate", myfilename
Everything seems to work but when i try to open the file it gives a message Format or File Extension not valid. I deleted the file and did it over and it still produces the same error.  Thanks for any help.
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of marlind605

ASKER

That was the quickest solution I ever got to one of my questions. Thanks.
Did you catch what the problem was?
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryalltimerecordsbydate", myfilename
This is the filetype for a .xls export, and you specified a .xlsx filename
Hence the problem
acSpreadsheetTypeExcel9 has a value of 8

Rey had you substitute in 10 to match the .xlsx filetype.