Hello CJ_London,As I stated in post #2 the is nothing wrong with the code so the issue has to be with the query. Either misspelled or requires parameters (name implies it is an xtab so any parameters must be declared)
we are now 17 posts in and the OP would appear to be ignoring this simple check
Sorry pat, i don't get your suggestion..Except that the extension doesn't match the export type. The .xlsx extension is the XML format but the type is the macro format. That seems to jibe with the error message.
This works
Code:DoCmd.OutputTo acOutputQuery, "qry1",acformatxlsx,"F:\temp\qry1.xlsx",,,,acExportQualityPrint
Yours is
Code:DoCmd.OutputTo acOutputQuery, "qryCrosstab_Payment", acFormatXLSX, FileName, , , , acExportQualityPrint
I cannot see any difference?
Debug.Print FileName and report back here.
Can you change the folder to somewhere else? Hardcode a filename and path just as a test.
Can you actually write to your desktop?
I tried the exact code with a query of my own - and it worked without a problem.Except that the extension doesn't match the export type. The .xlsx extension is the XML format but the type is the macro format. That seems to jibe with the error message.
you just did itMy appologies sir.. and i am not ignoring the suggested check.. but some i can't do it as i don't know how to do it.
all you didn't say is how many rows it producesthe query has no parameters, it is opening and shows the records..
I thought macros were .xlsm ?What part of
acFormatXLSX is the name for the MACRO format and acSpreadsheetTypeExcel12Xml is the name for the STANDARD format did you not understand? Please just try replacing the correct name for what you have.
So, you tell Access to export a macro enabled spreadsheet but you name it incorrectly to .xlsx. What do you end up with?I tried the exact code with a query of my own - and it worked without a problem.
I guess I wasn't being clear. I'll try again. There are two argument values for the TransferSpreadsheet for version 12. One to create a macro workbook (acSpreadsheetTypeExcel12) and the other to create a normal workbook (acSpreadsheetTypeExcel12Xml). The OP was using the argument to create the macro workbook but was naming the workbook with the normal extension.Macro enabled workbooks are .xls, .xlm, xlb, xlsm or xlsb AFAIK?
I don’t see where the OP has said that and I see no code to indicate they are adding macros to the newly created file.The OP said to create a macro workbook but he gave it the wrong extensio
@Pat Hartman.I guess I wasn't being clear. I'll try again. There are two argument values for the TransferSpreadsheet for version 12. One to create a macro workbook (acSpreadsheetTypeExcel12) and the other to create a normal workbook (acSpreadsheetTypeExcel12Xml). The OP was using the argument to create the macro workbook but was naming the workbook with the normal extension.
CJ said it doesn't matter but the two types of workbooks have different formats so the question becomes, what do you end up with? The OP said to create a macro workbook but he gave it the wrong extension so does the file end up with the binary format or the XML format? Is the workbook going to be blocked by some other application if the internal format is binary rather than XML even though the extension is .xlsx?