I use SPSS 15 to create several Excel reports, which I then compile using an Excel macro. Unfortunately, this version of SPSS creates .xls files that are easy to read for Excel 2007 and later. Excel 2003 accumulates these files, but newer versions of Excel display two error messages. First of all, "Excel found unreadable content in filename.xls. Do you want to restore the contents of this workbook?" After clicking yes, it is followed by βFile error: data may be lost.β Unfortunately, these error messages cause my macro to exit in the first file with error code 1004. This is the code I use to open my Excel files:
If Len(Dir(ThisWorkbook.Path + "\filename.xls")) <> 0 Then Workbooks.Open Filename:=ThisWorkbook.Path + "\filename.xls" End If
I checked with IBM (SPSS providers) and they told me that this problem was fixed in SPSS 16, but for business reasons the update is not on the maps. Now there is a manual workaround that involves opening files and saving again, but with dozens of files that are obviously not interesting. Therefore, I am looking for a way to automatically repair these damaged books in my macro.
Additional information: we use Excel 2010 at work, Excel 2003 is not available. An example file can be found here: https://onedrive.live.com/?cid=52106BC267261CBF&id=52106BC267261CBF!292
vba excel-vba excel spss
Haris
source share