How to open a password protected word document using Matlab?
2 views (last 30 days)
Show older comments
Hi,
Would you please help me in writing a code in matlab to open a password protected word document?
below is the code I tried, but it does not work. please help me. Thank you.
[filename, pathname] = uigetfile('*.docx','Select a file','C:\');
filename = [filename,'.docx'];
password = 'secret';
passopen(filename,password);
function passopen(filename, password)
%Example filename = 'file.doc' and password = 'password'
Word = actxserver('Word.Application');
set(Word,'Visible',1);
[fpath,fname,fext] = fileparts(filename);
if isempty(fpath) out_path = pwd;
elseif fpath(1)=='.' out_path = [pwd filesep fpath];
else out_path = fpath;
end
try
Document=Word.Documents.Open([out_path filesep fname fext],0,0,0, password);
catch
error('Cannot open file and/or file does not exist!');
end
The output is : error??? Cannot open file and/or file does not exist! error in --> passopen(filename,password);
0 Comments
Answers (0)
See Also
Categories
Find more on Search Path in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!