Most likely it didn't work from the command line for you either.

This is because notepad.exe is in the program search path ($ENV{PATH}), while excel.exe is not.

You should use fully qualified program names and the list form of system(), but you still have to find Excel for yourself:

use strict; my $excel = 'c:/Programs/Microsoft Office/Excel/excel.exe'; my $file = "c:\\path\\to\\my test.xls"; # note that Excel might want the filename delimited # with backslashes system( $excel, $file ) == 0 or die "Couldn't start Excel: $^E / $! / $?";

Another possibility is to rely on Windows to do the Right Thing and just let the default Windows action on a .xls file take place:

use strict; my $file = "c:\\path\\to\\my test.xls"; # note that cmd.exe wants the filename delimited # with backslashes system( 'start', $file );

And, if you need more control than that, there is always Win32::OLE, with which you can automate Excel:

use strict; use Win32::OLE; my $excel = Win32::OLE->new( 'Excel.Application' ); my $file = "c:\\path\\to\\my test.xls"; $excel->Open( $file ); # or so I believe. Use the Macro Recorder to find out # what the function names are actually called

In reply to Re: Calling Excel by Corion
in thread Calling Excel by Anonymous Monk

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.