Lionel
Lionel

Reputation: 3288

How do I insert multiple figures into multiple tables in Matlab?

Here's what I'm trying to achieve in MATLAB:

Page 1

______________
|      |     |
| Fig1 | Fig2|
|      |     |
|______|_____|
|      |     |
| Fig3 | Fig4|
|      |     |
|______|_____|

Page 2

______________
|      |     |
| Fig5 | Fig6|
|      |     |
|______|_____|
|      |     |
| Fig7 | Fig8|
|      |     |
|______|_____|

I can't figure out the parameter to pass InsertBreak to get a new page:

word = actxserver('Word.Application');

word.Visible = 1;

op = invoke(word.Documents,'Add');

active=word.ActiveDocument;

%% Table 1
% Create 4x4 table
range=word.Selection.Range;
shapes=word.Selection.InlineShapes;
t=invoke(word.ActiveDocument.Tables,'add',range,2,2);

% fill each cell with an image, image will fit to table
invoke(shapes,'addpicture',fullfile(pwd, 'fig1.wmf'));

invoke(word.Selection,'moveright',1,1);
invoke(shapes,'addpicture',fullfile(pwd, 'fig2.wmf'));

invoke(word.Selection,'moveright',1,2);
invoke(shapes,'addpicture',fullfile(pwd, 'fig3.wmf'));

invoke(word.Selection,'moveright',1,1);
invoke(shapes,'addpicture',fullfile(pwd, 'fig4.wmf'));

%% Table 2, I want this on a new page
invoke(word.Selection,'InsertBreak',2); % how do I get the next stuff on a new page?
range=word.Selection.Range;
shapes=word.Selection.InlineShapes;
t=invoke(word.ActiveDocument.Tables,'add',range,1,2);

invoke(shapes,'addpicture',fullfile(pwd, 'fig1.wmf'));
invoke(word.Selection,'moveright',1,1);
invoke(shapes,'addpicture',fullfile(pwd, 'fig2.wmf'));

Upvotes: 3

Views: 1423

Answers (1)

b3.
b3.

Reputation: 7165

Try the following in place of your InsertBreak line. It moves the start of the selection to the end of the document. Without the move your code is inserting a page break inside a table cell.

invoke(word.Selection, 'MoveStart', 6);
invoke(word.Selection, 'InsertBreak');

Upvotes: 1

Related Questions