Hi Monks,
I need to execute a vbscript which opens a .xlsm file with some vba macro and does some processing in it and saves the file as another output file. I am able to execute the vbscript independently on cmd. However when I run it via my perl code, it gives error on the apache error log, that
it can't access the file specified in the path 'C:\\Program Files (x86)\\Apache Software Foundation\\Apache2.2\\htdocs\\TestWeb\\test.xlsm ' There are several possible reasons:\r,
\x07 The file name or path does not exist.\r
\x07 The file is being used by another program.\r
\x07 The workbook you are trying to save has the same name as a currently open workbook.\r
My perl code is as follows
`cscript test.vbs arg1 arg2 filename.xlsm`;
sleep(20);
if(-e filename.xlsm){
print "File generated";
}else{
print "File Not found";
I am giving the sleep since the script takes some time to execute the macros and generate the .xlsm file. However nothing is working. I am invoking this from a webpage hosted on apache and on windows 2008 server.
Alternatively, I tried usin Win32::OLE to access the excel
use Win32::OLE qw(in with);
use Win32::OLE::Const ('Microsoft Excel');
my $excel = Win32::OLE->CreateObject('Excel.Application') || Win32::OL
+E->new( 'Excel.Application', 'Quit' );
my $wrk_book = $excel->Workbooks->Open('C:/Program Files (x86)/Apache
+Software Foundation/Apache2.2/htdocs/TestWeb/test.xlsm');
$excel->Run('CreateAdhocMDL',$arg1,$arg2, $filename );
$excel->{Visible} = 1;
$excel->$wrk_book->SaveAs("C:/Program Files (x86)/Apache Software Foun
+dation/Apache2.2/htdocs/LFWeb/$filename");
$excel->Close();
However, this gives error,"Can't locate object method "SaveAs" via package "Microsoft Excel", perhaps you forgot to load Microsoft Excel".
Appreciate any inputs.
Thanks