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')
Best Answer