Note that there are some explanatory texts on larger screens.

plurals
  1. POPerl fails to open excel file when executing from Windows Task Scheduler
    primarykey
    data
    text
    <p>This is a very bizarre problem. I have a Perl (version 5.12) script that opens and modifies an Excel spreadsheet (version 2007 or later). Below is the Perl code to open Excel file:</p> <pre><code>my $excel = Win32::OLE-&gt;GetActiveObject('Excel.Application') || Win32::OLE-&gt;new('Excel.Application', 'Quit'); my $book = $excel-&gt;Workbooks-&gt;Open($excelPath) or die $!; </code></pre> <p>The entire Perl script is added into the Task Scheduler in Windows Server 2008 R2 because it will be called at the same time every day. When I run the script from Task Scheduler, an error occurs at the "Open" statement above and aborts, but $! is completely blank.</p> <p>However, when I run the Perl script manually from command line, everything works fine including the open-Excel logic. I can't figure out the difference between a command-line execution and a scheduler execution, and why no error message is available when the Open fails.</p> <p>Please let me know if you have any clue about this issue. Thanks.</p> <p><strong>Update</strong>: Thanks to Jason Gray, I'm able to see the error message, which complains that the Excel file cannot be accessed. But this doesn't make sense to me because I can guarantee that file path is correct and that no one else is using the same file. Most importantly, the Perl script works perfectly when running from command window. What might be difference between running from Task Scheduler and running from command line?</p> <p><strong>Solved!</strong> I found an odd solution to this odd problem. Please refer to these links: <a href="http://www.accessforums.net/programming/macro-having-issues-when-run-windows-scheduler-16921.html" rel="nofollow">Link1</a> <a href="http://social.msdn.microsoft.com/Forums/en-US/innovateonoffice/thread/b81a3c4e-62db-488b-af06-44421818ef91" rel="nofollow">Link2</a> <a href="http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/4d6c383a-94eb-4898-9d22-aa4bb69be25b" rel="nofollow">Link3</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload