1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| clc
clear all
WordFileName='TestDoc.doc';
CurDir=pwd;
FileSpec = fullfile(CurDir,WordFileName);
actx_Word = actxserver('Word.Application');
actx_Word.Visible = true;
trace(actx_Word.Visible);
if ~exist(FileSpec,'file');
% Create new document:
word_handle = invoke(actx_Word.Documents,'Add');
else
% Open existing document:
word_handle = invoke(actx_Word.Documents,'Open',FileSpec);
end
actx_Word.Selection.Borders.Enable = 1;
TextString='Texte encadré';
actx_Word.Selection.TypeText(TextString);
actx_Word.Selection.TypeParagraph; %enter
actx_Word.Selection.Borders.Enable = 0;
TextString='Texte PAS encadré';
actx_Word.Selection.TypeText(TextString);
actx_Word.Selection.TypeParagraph; %enter |
Partager