Getting error MATLAB:COM:E2148140012 from compiled module starting Excel
18 views (last 30 days)
Show older comments
Perhaps this is not the right place for this question, since it might be OS related, but it might still be usefull.
I'm running a compiled MatLab module, which is started from a windows service. This service starts Excel to create a report, but I get the error MATLAB:COM:E2148140012.
This happens on a windows server 2012R2 machine. With the exact same configuration it works fine on a windows server 2008 machine.
On both environments the windows service runs on Local System account.
Do you have any idea what is necessary for a Mathlab module to run Excel in the sence of security?
0 Comments
Answers (1)
Cheng Tsai
on 4 Oct 2016
Edited: Cheng Tsai
on 4 Oct 2016
If you're coming down this rabbit hole, chances are you're trying to run run excel through matlab non-interactively (for example as a service or scheduled command).
Excel was not meant to run in the background unattended, but personally I see no technical reason why MS can't address this.
Some of these exceptions give misleading error messages, such as COM exception MATLAB:COM:E2148140012 Invoke Error Dispatch exception, cannot access the file 'blah blah' when doing xlsread() . When you convert that number to hexidecimal, you get MATLAB:COM:E 0x800A03EC . The 'cannot access file' actually makes sense when you consider Excel cannot access the Desktop path (and you can see this OS call result in "Not Found" if you do a file trace).
So try this one before messing with DCOM permissions. Excel likes to have access to a desktop directory. When you use Excel in your MCC compiled application running in the background, it is also looking for that Desktop directory, but because the user profile isn't always fully loaded, it can't find a desktop directory and you will run into problems.
Two of the default locations are as follows: 'c:\windows\system32\config\systemprofile\desktop' % for x64-excel on x64 hardware, or x86 on x86
'c:\windows\syswow64\config\systemprofile\desktop' % for x86-excel on x64 hardware
You will only need one, but go ahead and create both. Create these folders with an admin account and then run your remote app as non-elevated user.
As far as my testing and file tracing has determined, no files are persisted here. Excel just opens the folder and I think xlswrite will put a temp file there and moved it.
For reference: https://social.msdn.microsoft.com/Forums/office/en-US/ac2549f5-fc1e-494d-9015-70cb31d3aeb2/opening-excel-workbook-fails-when-run-from-scheduled-task-on-windows-server-2008-rw?forum=exceldev
2 Comments
Nick Patterson
on 21 May 2020
Awesome! I've been banging my head against this issue for a while, and this definitely solved the problem!!
Thijmen
on 10 Oct 2024
Edited: Thijmen
on 10 Oct 2024
Thanks a lot! Definitely couln't have found this myself..
In my case, the error occured in plain Matlab (R2015b, not involving MCR) which was run as a background process.
Initial symptoms were:
Error using writetable (line 116)
Error writing table variable 'Xxx' to 'C:\Yyy\Zzz.xlsx':
After some further digging, I found it was caused by `MATLAB:table:write:XlsWriteFailed`, in toolbox\matlab\datatypes\@table\writeXLSFile.m which also uses xlswrite.
See Also
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!