When trying to figure out how to do something in Excel with Win32::OLE, I find it very useful to record a macros to do the task(s) and then check out the source code of the macros. Then I just grab the relevant portions and convert it into Perl code.
Since I happen to have access to a system with Excel 2007 installed on it, I created a blank Excel 2007 file (.xlsx file extension) and recorded a macros to save it as an Excel 2003 format file. Based on the macros source code, it looks like your file format is in correct. It should be xlExcel8.
Also, I pulled my source code of a script that I wrote late last year that did this exact thing. In that code, I had the file format as xlExcel8.
So just change the following line
$xlBook->SaveAs({Filename=>"$excelFile",FileFormat=>xlExcel9795});so that it becomes the following
$xlBook->SaveAs({Filename=>"$excelFile",FileFormat=>xlExcel8});Without testing the rest of your code, I think that should fix it. Of course, I'd suggest that you add in use strict; and use warnings; as davies suggested. Also, if you try his other suggestion of making Excel visible, it will help debug any situations where Excel is using a pop-up window to get input from the user. Once you've got the bugs worked out, you can set Excel to be invisible again if you don't want to watch Excel do what your script tells it to do.
In reply to Re: Win32::OLE - Excel, Can't save as Previous Version
by dasgar
in thread Win32::OLE - Excel, Can't save as Previous Version
by JaySal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |