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.
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?
Dear all,@Gasman Apparently the OutputTo has different arguments than TransferSpreadsheet does and so cannot create the other format spreadsheet.
Moi has language issues and so has trouble following directions and that makes him very difficult to help. Perhaps he will understand my last suggestion and get the dots out of the file name and try that. Or, try using the TransferSpreadsheet and perhaps get a different error message which will help to identify the problem.
Please share your final solution. It will help other users here who may have the same problem.I sorted thank you