I am working on a VBA macro which will process a CSV file by creating a temporary file.
I am using Microsoft Excel 2010 32-bit
. The 32-bit versions have the 2 Gigabyte
memory limits.
The size of CSV file that is being processed using macro is > 1GB.
As stated previously, while processing the CSV file we are saving it to a temporary *xls file.
So the total size while processing the CSV file will be the size of CSV file
+ size of the temp xls
file that we are creating during the processing.
The size of both the files together is beyond the limit of 2GB and hence excel is crashing.
We have 2 scenarios:
- When the user opens a CSV file using macro, I show a message box to the user if the user opens a CSV file whose size is > 1GB and close the excel.
- When the user opens a CSV file using macro, and the CSV file size < 1GB and then user adds some data to it which will make its size > 1GB, I have to show a message box to the user as soon as the file size reaches 1GB and close the excel without losing any data.
My question,
- For the first case, I can use FileLen which returns a Long value specifying the length of a file in bytes.
- For the second case: I am not getting how to calculate the file size when user is editing the CSV file using macro.
Need help, Thanks in advance.