Sneha has asked for the wisdom of the Perl Monks concerning the following question:

Hi All, I want to run Perl Script from Excel using VBA functions.I used the Shell function but nothing happen. Is there any way to run Perl script from Excel.

Replies are listed 'Best First'.
Re: Calling Perl script from Excel
by Corion (Patriarch) on Mar 04, 2009 at 09:20 UTC

    You must be doing it wrong then, because using Shell from Excel works to run a Perl program. What error did the Shell function raise? Most likely, it will help if you start your script as Shell "perl -w c:\full\path\to\perl\script.pl some commands". But this is mostly a Visual Basic (for Applications) question and not a Perl question and hence off-topic here.

Re: Calling Perl script from Excel
by ELISHEVA (Prior) on Mar 04, 2009 at 09:32 UTC
    The VBA shell function runs a shell command immediately and then returns. It doesn't wait for the command to finish and it doesn't provide for a way to get the command's standard out stream or even exit code. That may be why you are getting "no result".

    If you are expecting information back from your Perl script, there are some alternatives. You could try the recommendataions here, but as you can see its pretty long-winded and complicated code. This link supposedly provides a function that waits till the command is done, but even it doesn't get you the output to STDOUT or the exit code. You would have to make additional arrangements to write to and read from a named output file if you need output from your command.

    I've never tried this script, so use at your own risk. Personally, I haven't had much luck getting Excel to wait and return results from external commands reliably.

    Best, beth

Re: Calling Perl script from Excel
by leslie (Pilgrim) on Mar 04, 2009 at 10:09 UTC
    Hi monks,

    Please gone through this below url. http://www.codeproject.com/KB/perl/ExecPerlFromVBA.aspx