xlswrite fails when run from Task Scheduler
2 views (last 30 days)
Show older comments
I have a routine that creates an Excel spreadsheet that I want to run every day from the Microsoft Task Scheduler. When I execute directly from MATLAB, or from a Microsoft shortcut, the routine works without error, however, fails when I use the Task Scheduler.
The MATLAB version is R2014b and the Windows version is Windows 7, Windows Server 2008 R2.
Here is sample write.
if (strncmp(cosMGD, 'No Data', 7) == 0)
xx = cosMGD(1,2:30);
xlswrite ('WPQO/Toolbox/Short Term Plan Report.xlsx', xx',...
'schedule', 'C5:C33');
else
disp 'COS Actuals Production Schedule data NOT Available';
end;
I get the following error messages when I execute from the Task Scheduler. MATLAB hangs up.
Error using <a href="matlab:matlab.internal.language.introspective.errorDocCallback('xlswrite', 'C:\Program Files\MATLAB\R2014b\toolbox\matlab\iofun\xlswrite.m', 219)" style="font-weight:bold">xlswrite</a> (<a href="matlab: opentoline('C:\Program Files\MATLAB\R2014b\toolbox\matlab\iofun\xlswrite.m',219,0)">line 219</a>)
Invoke Error, Dispatch Exception:
Source: Microsoft Excel
Description: Microsoft Excel cannot access the file
'C:\Users\emainc\Documents\MATLAB\WPQO\Toolbox\Short
Term Plan Report.xlsx'. There are several possible reasons:
• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook.
Help File: xlmain11.chm
Help Context ID: 0
Error in <a href="matlab:matlab.internal.language.introspective.errorDocCallback('shortTermPlanReport', 'C:\Users\emainc\Documents\MATLAB\WPQO\Toolbox\shortTermPlanReport.m', 169)" style="font-weight:bold">shortTermPlanReport</a> (<a href="matlab: opentoline('C:\Users\emainc\Documents\MATLAB\WPQO\Toolbox\shortTermPlanReport.m',169,0)">line 169</a>)
xlswrite ('WPQO/Toolbox/Short Term Plan
Report.xlsx', xx',...
Error in <a href="matlab:matlab.internal.language.introspective.errorDocCallback('daily_report', 'C:\Users\emainc\Documents\MATLAB\WPQO\daily_report.m', 46)" style="font-weight:bold">daily_report</a> (<a href="matlab: opentoline('C:\Users\emainc\Documents\MATLAB\WPQO\daily_report.m',46,0)">line 46</a>)
shortTermPlanReport(refDate); % Short Term Plan Report
The Task Scheduler parameters are as follows:
Name: Matlab WPQO Short Term Daily Report
Description: Water Production Quality Optimizer (WPQO) – Short Term Daily Report
Trigger: Daily at 6:30 AM every day
Program/Script: "C:\Program Files\MATLAB\R2014b\bin\matlab.exe"
Add arguments: -logfile "C:\Data\LOGFILE\ReportLog.txt" -r "daily_report; exit"
4 Comments
Daryl
on 15 Nov 2017
Seems to be some strange problem unrelated to MATLAB ... http://justgeeks.blogspot.com.au/2012/10/troubleshooting-microsoft-excel-cannot.html
Victor Villar
on 24 May 2019
Edited: Walter Roberson
on 24 May 2019
Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!