2011-03-29 101 views
3

這裏就是我試圖在MATLAB來實現:如何在Matlab中將多個圖形插入多個表格中?

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

第2頁

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

我想不通的參數傳遞InsertBreak得到一個新的頁碼:

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')); 

回答

1

請嘗試以下操作代替您的InsertBreak線。它將選擇的開始移動到文檔的末尾。如果沒有移動,代碼會在表格單元格中插入分頁符。

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