MATLAB Answers

0

Error "xls is not writable. It might be locked by another process" from exe file but not from m file.

Asked by Kelly Kyriakou on 9 Nov 2015
Latest activity Commented on by Kelly Kyriakou on 10 Nov 2015
Hello,
I have written code that opens an excel file, read it and show it to user and then export the data to xls file through xlswrite command. When I run it in matlab it works fine. However, when I compiled it through matlab compiler it opens and shows the data but cannot write the xls file. I opened cmd.exe to see the error and get the following error " nameofexcel.xls is not writable. It might be locked by another process". So, I wrote code if this excel file is open to close it and then write but still it doesn't work. Do you have any suggestions?
Thank you in advance

  1 Comment

Actually, I discovered the problem. I hadn't the rights to write a file at the destination folder. I changed the rights and it works. The destination folder was created in program files. Do you have to suggest any destination that will have the rights to write?

Sign in to comment.

1 Answer

Answer by Image Analyst
on 10 Nov 2015
 Accepted Answer

Kelly, Windows does not allow programs (except installers) to write to any files under c:\Program Files. So what I do is to have my m-files on a second internal SSD - no problem writing there. If you want to keep it on your C drive, put the results in your input data folder (if it's not under Program Files) or in your C:\users\Public\Documents folder. You can also make subfolders under there if you want. Every program and user should be allowed to write files to that folder.

  1 Comment

Ok, I will change destination path to path that you suggest me. Thank you very much

Sign in to comment.