xlswrite Function 'openExcelWorkbook' Not Working! (New 05/2023)

4 views (last 30 days)
Hello all,
I am having trouble with function xlswrite. I have used it countless times before with the same exact script earlier this year. Today, however, I am receiving an error message despite no changes to my MS Excel licensure/version or MATLAB licensure/version. I have not updated security protections either. Essentially, nothing has been intentionally changed on my end since last using xlswrite in January.
On MATLAB 2018b, I get the following error message:
Error using xlswrite (line 224)
Undefined function 'openExcelWorkbook' for input arguments of type 'COM.Excel_Application'.
On MATLAB 2021a, I get the following error message:
Unrecognized function or variable 'openExcelWorkbook'.
Error in xlswrite (line 224)
theMessage = exceptionHandler(nargout, exception);
I could not find documentation nor previous questions raised which involve these error messages. Any thoughts?
  2 Comments
dpb
dpb on 22 May 2023
What does
which -all openExcelWorkbook
return? It's a private function called by xlswrite; the messages make it look like it isn't being found, but seems hard to imagine would have scrogged two versions -- unless, of course, you somehow have a piece of code that uses that name for something else...
Michael Diaz
Michael Diaz on 22 May 2023
C:\Program Files\MATLAB\R2021a\toolbox\matlab\iofun\private\openExcelWorkbook.m % Private to iofun

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 22 May 2023
Can you start Excel by itself without it asking you anything? What happened to me was that my systems were changed from using Excel 2016 to using Excel/Office 365. This ended up breaking all my programs because when I went to toss some data into Excel, it failed. For example, Office 365 requires everyone to login to Office at least once. So when my users went to a shared lab system and logged in under their own username to the system, and ran my program, my program called up Excel as an ActiveX server and then tried to throw data into it, and that failed. The cause was that now it was Office 365 that was running and my user was supposed to login to office. However, this login prompt happened immediately, even before I could set the Visibility property to true! So my user never saw the login prompt and my attempt to use Excel after that failed. With the prior version of Excel, we did not have to have each user login individually. The fix was that I have to have my users start Excel on it's own and login, once. Once that is done, then I can get an ActiveX server without it asking my users to login anymore. The problem is we have many users and they change lab technicians all the time. We are looking into getting something called something like a "long term service contract" where the Excel is for the whole machine, like it used to be, rather than for each individual users like it is now with Office 365. However they'll do that only until 2025 when Windows 10 and that version of office will have "end of life".
So bottom line, try to start Excel by itself first and answer any prompts it puts up. Then see if you can start it from MATLAB.
Another option is to change your call call from xlswrite to writecell or writematrix.
  8 Comments
dpb
dpb on 22 May 2023
IA, I'm also curious re: your suggestion to use the writeXXX family instead -- do they actually behave differently in not requiring the login? That would be useful certainly, and interesting to know if they can bypass such or if they just somehow manage to display the login prompt instead of failing.
The big problem still is they also suffer from the problem that they open/close (and I presume create/destroy) the file/COM object on every call as does xlswrite. This is ok for moderately dense operations on a file, but I've found they become excessively slow and can even hang the machine if try to write very large numbers of cells in sequential calls when it is inconvenient/difficult to create all the data a priori and update/write the whole file (or at least significant fractions of it) in one operation.
These routines need a helper option that would let the user control when the actx server/file is opened/closed to be able to open the file, work on it a while with mulitple calls, then close when done.
Image Analyst
Image Analyst on 23 May 2023
Edited: Image Analyst on 23 May 2023
Yeah, Office 365 is not so reliable. In January, March and April 2023 it had problems. In fact, it had problems just yesterday:
May 22, 2023: "We're investigating an issue affecting access to https://msft.it/6016gbJ06 and Microsoft 365 apps," the company said. Additional updates can be found at https://msft.it/6017gbJ0B under MO559201."

Sign in to comment.

Categories

Find more on MATLAB Report Generator in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!