Home: Perl Programming Help: Win32 Programming Help:
%1 is not a valid Win32 application.

New User

Aug 31, 2010, 9:08 PM

Views: 13083
%1 is not a valid Win32 application.

#!/usr/bin/perl -w 

use strict;
use OLE;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';

$Win32::OLE::Warn = 3; # die on errors...
print "Content-type: text/html\n\n";

print "init <BR>";
my $Excel = CreateObject OLE 'Excel.Application';
print "excel init_ <BR>";
my $Book = $Excel->Workbooks->Open("D:/template.xls");
print "excel file loaded <BR>";

my $Sheet = $Book->Worksheets(1);

foreach my $row (1..9)
foreach my $col (1..3)
next unless defined $Sheet->Cells($row,$col)->{'Value'};
printf "At ($row, $col) the value is %s and the formula is %s\n",

$Sheet->Cells(6, 1)->{'Value'} = 'MODTEST';
print "excel file modified <BR>";
$Book->SaveAs({Filename =>'D:/record.xls',
FileFormat => xlWorkbookNormal});
print "excel file saved <BR>";


print "excel quit successfully<BR>";

The script runs fine when i run it straight from command prompt
But when i run it on the site
it throws me the error
-> %1 is not a valid Win32 application.

Anyone encounter this errror before ?