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

In reply to Execute VBScript in perl to work on .xlsm by suzun30

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.