I am using MATLAB to write to an Excel file with Macros in them, and then reevaluate the file and extract the Macro results using xlsread. The code works fine with only one worker. However, if I use parfor and use a second worker, MATLAB gives the error message as below. To be rigorous, I have created a second Excel file for the second worker and use t = getCurrentTask(); t.ID; to instruct the workers to work on their arranged excel file.
Error using xlswrite (line 226)
Invoke Error, Dispatch Exception: Source: Microsoft Excel Description: Microsoft Excel cannot access the file 'C:\Users-----\D0481000'. 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 extractFromExcelExpress (line 249) xlswrite(filename,writtenIn,sheet,'B23');
This happens randomly. I did try to change the folder of the excel files and it starts to work for hours but ultimately stops. I did clear all the add-ins in Excel and I did put the corresponding folder to the excel trust locations.
The Excel version: 2016
The MATLAB version: R2017a
xlsreadandxlswriteare terribly slow, throwing aparforat the problem is not the answer. - Wolfie