1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| WordFileName='TestDoc.doc';
CurDir=pwd;
FileSpec = fullfile(CurDir,WordFileName);
[ActXWord,WordHandle]=StartWord(FileSpec);
function [actx_word,word_handle]=StartWord(word_file_p)
% Start an ActiveX session with Word:
actx_word = actxserver('Word.Application');
actx_word.Visible = true;
trace(actx_word.Visible);
if ~exist(word_file_p,'file');
% Create new document:
word_handle = invoke(actx_word.Documents,'Add');
else
% Open existing document:
word_handle = invoke(actx_word.Documents,'Open',word_file_p);
end
return |
Partager