Unprotect excel file from matlab
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I am using the ProtecStatus2 file from the File Exchange to open a protected excel file. It doesn't work.
Excel = actxserver('Excel.Application');
Excel.visible = 1;
Woorkbooks = get( Excel, 'Workbooks' );
invoke(Woorkbooks, 'open', [pwd 'Book1.xlsx']);
ProtecStatus2(Excel, 'DONOTBREAK');
Error using
Interface.Microsoft_Excel_15.0_Object_Library.Workbooks/invoke
Invoke Error, Dispatch Exception:
Source: Microsoft Excel
Description: Sorry, we couldn't find C:\Users\Cedric\Desktop\Learning
GUIBook1.xlsx. Is it possible it was moved, renamed or deleted?
Help File: xlmain11.chm
Help Context ID: 0
Error in PassUnprotect (line 4)
invoke(Woorkbooks, 'open', [pwd 'Book1.xlsx']);
I also tried using the xlsprotect function from the File Exchange, But, it also doesn't work even after I use xlsread.
xlsprotect('Book1.xls','unprotect_file','DONOTBREAK');
[NUM,TXT,RAW]=xlsread('Book1.xls');
Error using
Interface.Microsoft_Excel_15.0_Object_Library.Workbooks/invoke
Invoke Error, Dispatch Exception:
Source: Microsoft Excel
Description: Sorry, we couldn't find C:\Users\Cedric\Desktop\Learning
GUI\Book1.xls. Is it possible it was moved, renamed or deleted?
Help File: xlmain11.chm
Help Context ID: 0
Error in xlsxprotect (line 120)
Workbook =
invoke(Excel.Workbooks,'open',file,0,0,1,varargin{1});
Error in PassUnprotect (line 3)
xlsprotect('Book1.xls','unprotect_file','DONOTBREAK');
What is going on here?
It has been a month that I've tried to figure this out, and I am really depressed.
Please help me, I need anyone's help.
I am getting nuts about this.
5 commentaires
Ahmed A. Selman
le 18 Avr 2013
What version of Windows (or any other OS) you're using? Perhaps removing the directory entirely to another (safer) place, say, D:\, might solve the issue. I think it's all about permission to change contents of some file in a Windows protected directory (\Users, in this case), and it's a common behavior of Windows 7.
Besides, you've used (book1.xls) and (Book1.xlsx) in the question above. I think you recognize that filename extension .xls is (excel 2003 down), and .xlsx is (excel 2007 up).
Réponses (1)
Friedrich
le 17 Avr 2013
Modifié(e) : Friedrich
le 17 Avr 2013
Hi,
the error you get:
Sorry, we couldn't find C:\Users\Cedric\Desktop\Learning
GUIBook1.xlsx
suggests a missing \ after GUI, doesnt it? Generating a path with [pwd 'Book1.xlsx'] is always a bad idea. Better is to use
fullfile(pwd,'Book1.xlsx')
When you did xlsread the path seems to be correct:
xlsread('Book1.xls');
Sorry, we couldn't find C:\Users\Cedric\Desktop\Learning
GUI\Book1.xls
However there is an x missing at the end, doesnt it? Book1.xlsX <=
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!