Placing a figure into word and specifiying a position using ActiveX

조회 수: 19 (최근 30일)
lydie Nsangou
lydie Nsangou 2021년 2월 27일
답변: Mario Malic 2021년 2월 28일
Please can someone help me ! i want to insert a figure in my word document in a specified page. i tried using Selection.GoTo but nothing seems to happen. here is my code i would like to open my word document and start writing or inserting figures on the second page
word = actxserver('word.Application');
doc=invoke(word.Range.Add);
word.Visible =true;
word.selection.Style='Heading 1';
word.Selection.TypeText='Introduction';
word.Selection.InsertBreak(7); %pagebreak
i would like to skip the first page and start writing from the second!
thanks in advance for your help

답변 (1개)

Mario Malic
Mario Malic 2021년 2월 28일
Hi,
Selection points at current location where the text is going to be displayed, you have already typed something on first page. Afterwards you have inserted a Page Break, then the selection is on the second page. If you wanted to display text on the second page, then you would just use TypeText, because Selection is on that page.
word.Selection.Style='Heading 1';
word.Selection.TypeText='Introduction';
word.Selection.InsertBreak(7); %pagebreak
word.Selection.TypeText='Introduction on page 2';
An example of arguments for GoTo method to go to second page are shown below.
word.Selection.GoTo(1, 1, 2);

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by