MATLAB Answers

0

How to password protect an excel file through Matlab?

Asked by Partha Mitra on 11 Nov 2019 at 4:44
Latest activity Commented on by Partha Mitra on 11 Nov 2019 at 7:53
I am trying to password protect an excel file which is created using Matlab..
clc;clear;dFlag_Excel = 0;
xlsfile = 'Try_V1.xlsx';
password = 'Test';
Excel = actxserver('Excel.Application'); % open Excel as a COM Automation server
Workbooks = Excel.Workbooks;
Workbook = Workbooks.Open([pwd,'\',xlsfile]);
Workbook.Protect(password, 'True', 'True');
But i am getting an error in this last line above in the script:
??? Invoke Error, Dispatch Exception: The parameter is incorrect.
Error in ==> Untitled at 7
Workbook.Protect('Test@123', 'True', 'True')

  0 Comments

Sign in to comment.

Products


Release

R2010b

1 Answer

Answer by Nicolas Broch on 11 Nov 2019 at 7:34

I recommand you to use the xls_protect_sheets() from MATLAB exchange. It will be easier for you.

  1 Comment

This works but it only protects the sheet.
What I want is to protect the file completely.
I don't want others to open the file without a password.

Sign in to comment.