Perl fails to open excel file when executing from Windows Task Scheduler -


this bizarre problem. have perl (version 5.12) script opens , modifies excel spreadsheet (version 2007 or later). below perl code open excel file:

my $excel = win32::ole->getactiveobject('excel.application')             || win32::ole->new('excel.application', 'quit'); $book = $excel->workbooks->open($excelpath) or die $!; 

the entire perl script added task scheduler in windows server 2008 r2 because called @ same time every day. when run script task scheduler, error occurs @ "open" statement above , aborts, $! blank.

however, when run perl script manually command line, works fine including open-excel logic. can't figure out difference between command-line execution , scheduler execution, , why no error message available when open fails.

please let me know if have clue issue. thanks.

update: jason gray, i'm able see error message, complains excel file cannot accessed. doesn't make sense me because can guarantee file path correct , no 1 else using same file. importantly, perl script works when running command window. might difference between running task scheduler , running command line?

solved! found odd solution odd problem. please refer these links: link1 link2 link3

the win32::ole documentation explains when exceptions thrown/how catch them.

lasterror gives information error after has occurred.

you this:

my $book = $excel->workbooks->open($excelpath) ||             die("unable open document ", win32::ole->lasterror()); 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -