ExcelMacLean
New Member
- Joined
- Dec 1, 2015
- Messages
- 11
I create low-level automation solutions with Excel, these are usually small tools that accept user inputs, preform data calculations/manipulations, and generate outputs. I recently ran into a file-compatibility issue and need help. I am one small cog in a very large company and have no control over downstream tools. The output from my tool is zipped and fed into yet another tool downstream. It is this second tool that is rejecting my generated .xlsx file, and I do not know why.
Whats unusual is, some clever person fed my output into Microsoft Access as a Table, and then exported the same data again into Excel, and the new Access-Generated Excel file worked in the downstream automation. There was no other data-manipulation with access, and when compared visually the data in the two files is identical.
What is Access doing to generate a "cleaner" excel file? In my Excel VBA tool, the output data is stored as a variant array and then written directly to a new worksheet. I create a new workbook with Workbooks.add, the Variant Array is written directly to a Range (Range = VariantArray), then saved with Workbooks.SaveAs. In our test-files, the my final output file is 100kb. When the same data is imported into Access and then exported back to Excel, the file is 50kb, and works downstream.
To troubleshoot, I've tried executing Worksheet.ClearFormats on the new output worksheet before saving, and I've ensured the variant array contains no blank rows/Columns. My SaveAs function uses FileFormat:=xlOpenXMLWorkbook to generate the required .xlsx files. I do execute Range.NumberFormat = "@" on a range matching the VariantArray size before writing data because we deal with a lot of leading-zeros we cannot lose, so need the Text format, but after writing the data Range.NumberFormat = "General" to keep the files the same. I have a feeling this is why the files are different sizes, if Access is changing the datatypes? Any insight would be greatly appreciated.
Whats unusual is, some clever person fed my output into Microsoft Access as a Table, and then exported the same data again into Excel, and the new Access-Generated Excel file worked in the downstream automation. There was no other data-manipulation with access, and when compared visually the data in the two files is identical.
What is Access doing to generate a "cleaner" excel file? In my Excel VBA tool, the output data is stored as a variant array and then written directly to a new worksheet. I create a new workbook with Workbooks.add, the Variant Array is written directly to a Range (Range = VariantArray), then saved with Workbooks.SaveAs. In our test-files, the my final output file is 100kb. When the same data is imported into Access and then exported back to Excel, the file is 50kb, and works downstream.
To troubleshoot, I've tried executing Worksheet.ClearFormats on the new output worksheet before saving, and I've ensured the variant array contains no blank rows/Columns. My SaveAs function uses FileFormat:=xlOpenXMLWorkbook to generate the required .xlsx files. I do execute Range.NumberFormat = "@" on a range matching the VariantArray size before writing data because we deal with a lot of leading-zeros we cannot lose, so need the Text format, but after writing the data Range.NumberFormat = "General" to keep the files the same. I have a feeling this is why the files are different sizes, if Access is changing the datatypes? Any insight would be greatly appreciated.
Last edited: