Hi monks,
I am opening excel application through Win32::OLE & drawing a chart. Then trying to export the chart to PNG file. This works fine when executed directly. But if I Execute it through shell object from ASP throughs an error saying
Win32::OLE(0.1403) error 0x800a03ec
in METHOD/PROPERTYGET "Export" at C:\\timken_project\\export.pl li
+ne 35
Earlier I had the same problem & had posted it in perlmonks. This problem was solved after installing Office XP with SP1. But now I need to make the same thing working on Office 2003. I tried installing SP1 for Office 2003, but it didn't work. Why is it working on Office XP but not on Office 2003. Though it is not a perl problem any suggestions will be of great help.
The perl code to export the graph is
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
use Win32::OLE::Variant;
use Win32::OLE::NLS qw(:LOCALE :DATE);
use Win32::OLE;
use Win32::OLE::Const;
$Win32::OLE::Warn = 3; # die on errors...
$file = "C:\\testw.txt";
open (TTT, ">$file") || die "error";
print TTT "test";
$filename = "C:\\book1.xls";
$filter = 'PNG'; # can be GIF, JPG, JPEG or PNG
$pngnm = "C:\\test";
eval{
my $Excel = Win32::OLE->new('Excel.Application', 'Quit'); # use the Ex
+cel application if it's open, otherwise open new
my $Book = $Excel->Workbooks->Open( $filename ); # open the file
foreach my $Sheet (in $Book->Sheets)
{
# loop through all sheets
foreach my $ChartObj (in $Sheet->ChartObjects)
{
# loop through all chartobjects in the sheet
#$datewk = join("".split(/\s+/, $Date));
$savename = "$pngnm" . ".$filter";
#$savename = "$dirpath\\$pngnm" . ".$filter";
# Write image to PNG file
$ChartObj->Chart->Export({
FileName => $savename,
FilterName => $filter,
Interactive => 0
});
}
}
$Book->Close({SaveChanges=>0});
};
$err = $@;
print TTT $err;
Thanks in advance