Filter löschen
Filter löschen

How to open a password protected word document using Matlab?

2 Ansichten (letzte 30 Tage)
MatlabFan
MatlabFan am 1 Apr. 2013
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);

Antworten (0)

Kategorien

Mehr zu Search Path finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by