How do I stop this xlswrite error message?
Afficher commentaires plus anciens
I am writing a series of values to an excel sheet to do some quick comparisons with other data. Each value is a single number. Ex. caseyJan1992 = 52.6
This is my code for one of them.
xlswrite('casey_Hourly_443610_tp.xlsx',caseyJan1992,'MonthlySums','b14');
It is basically putting a single value into a one cell of a spreadsheet called "MonthlySums'. There are a bunch of these values going into spread sheet.
When I first open up MATLAB and run the code, it works fine. But, if I let MATLAB stay open for a few minutes or try to run the script more than once, I get this error message.
Error using xlswrite (line 224)
Invoke Error, Dispatch Exception:
Source: Microsoft Excel
Description: This command is unavailable because the license to use
this application has expired.
Help File: xlmain11.chm
Help Context ID:
My fix is to simply save my work and restart MATLAB.
This fix works, but it isn't a permanent solution and it takes more time away from what I need to do. Does anyone know of a more permanent solution?
7 commentaires
Walter Roberson
le 5 Avr 2019
Are you possibly using Office 365 with an expired license?
Cg Gc
le 5 Avr 2019
Walter Roberson
le 5 Avr 2019
Try starting up Excel itself and see what happens.
But in the meantime, if you have R2013b or later, switch to using writetable()
Cg Gc
le 5 Avr 2019
Walter Roberson
le 5 Avr 2019
The bit about starting up Excel was as to whether Excel gave you a message about the license or if it just ran okay.
You can use array2table() to create a table object to pass to writetable()
If you have a new enough MATLAB, you could use writematrix() instead of array2table() and writetable()
Guillaume
le 8 Avr 2019
As far as I understand writetable still use Excel by default (on Windows with Excel installed). It's only if you specify 'UseExcel', false that you don't need excel.
Walter Roberson
le 8 Avr 2019
Good point about the (fairly new) UseExcel parameter.
Réponses (2)
Javier Anguiano
le 19 Sep 2021
1 vote
I found that changinig the working directory to a short name solve the problem. I suppose that it's something related to the number of characters on the name and destiny of the final output. In my case, I set my working directory to C:/ and It works fine. The final destination/name of the file is not up to 20 characters.
1 commentaire
rahul
le 14 Oct 2024
I found even that was also not working .
Jan
le 5 Avr 2019
0 votes
It is not enough to think, that the license is active. Start Excel and check the license:
9 commentaires
Cg Gc
le 7 Avr 2019
Jan
le 8 Avr 2019
You didn't see the activation status? It should be easy to check, if the MS Office on your machine is activated. You do not need any assumptions about the university license to do this. Even running a shared computer activation can expire after a certain amount of time, if you do not reach the license server, e.g. because yout are not connected to the network of the university (e.g. by VPN?), or if the time of the machine differs too much from the time-zone of the license server.
Try this in a command shell:
cscript "%ProgramFiles(x86)%\Microsoft Office\Office16\OSPP.VBS" /dstatus
Replace "Office16" by your office version - look in the corresponding folder if you are not sure.
As long, as you do not confirm, that you have an active license, the most trustworthy statement is the error message, which tells you, that it is expired.
Guillaume
le 8 Avr 2019
You may want to black out your OneDrive university account as well.
What happens if in matlab you do:
excel = actxserver('Excel.Application');
You get the same error?
Are you connected to your university network when you attempt to xlsread. My understanding is that if Office can't talk to the network, it'll report that it's not activated.
Cg Gc
le 8 Avr 2019
Guillaume
le 9 Avr 2019
Oh, you certainly shouldn't get invalid ProgID! Get rid of the extra space after 'Application' and try again.
Jan
le 9 Avr 2019
@Cg Gc: Although you do not care about Guillaume's advice to black the personal information on the screenshots, I've edited them now. Do not post personal details like email address or GUIDs of your accounts.
Thanks for posting the screenshots. Now it is at least clear, which Office version you are using. Maybe this helps to check the license then:
It is not clear, if this is a Matlab problem, because it seems to concern the Office license only. Does using the debugger to step line by line through the code of xlswrite reveal which test is actually failing?
Cg Gc
le 9 Avr 2019
rahul
le 17 Fév 2026 à 5:15
Thank You for the revlavent answers.
Catégories
En savoir plus sur Spreadsheets dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


