Note: In the following code snippet, &w_die is a routine to write the error message to a log file before dying.

This code runs fine if I am actually logged in. However, when I try to set it up in Windows (Control Panel -> Scheduled Tasks) to read from an Excel file each day at a given time when I am not logged in, it fails.

(I AM able to read from an Oracle database this way using Scheduled Tasks when I am not logged in, with

use Win32::ODBC;
However, trying to do the same thing with Excel when not logged in fails.)

Here is the snippet:

... use OLE; # will read Excel workbooks ... eval {$excel = Win32::OLE->GetActiveObject('Excel.Application')}; &w_die("Excel not installed") if $@; ... $excel = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;}) or &w_die("Sorry, cannot start Excel\n"); ...
End of snippet.

The result in my logfile is:

Sorry, cannot start Excel

Again, this works fine if I am actually logged in. How can I get Perl to read from an Excel file at a given time when I am not logged in?

Thank you


In reply to When not logged in, using Win32::OLE for Excel fails by dana81

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.