How to adjust width and height of table and other table properties in Microsoft word document from MATLAB code and addition of picture in table?
25 views (last 30 days)
Show older comments
I have created Microdsoft word document using " c =actxword('Word.Application') " statement.In the document I have succesfully created table of 3X3 and 1st column is merged.
1.) Now I want to adjust the width of 1st and 3rd column and rows also.
2.) In first Column I want to add picture.
---------------------------------------------------------------------------------
c =actxserver('Word.Application')
c.Visible =1;
document=c.Documents.Add;
selection=c.Selection;
word.ActiveDocument.Tables.Add(word.Selection.Range,3,3);
tableObj = word.ActiveDocument.Tables.Item(1);
tableObj.Borders.Enable = 1; %create borders of table
handles.selection.MoveDown(5,3,1) %selection of first column
handles.selection.Cells.Merge() %Merge selected cells
handles.selection.MoveRight() % Move cursor to right
handles.selection.MoveRight(1,2,1) %selection of cells of 1st row and 2nd & 3rd column
handles.selection.Cells.Merge() %Merge selected cells
word.Selection.TypeText('text'); %Type text
handles.selection.MoveDown() % Move cursor downward
word.Selection.TypeText('text'); % type text
handles.selection.MoveRight() % Move cursor to right
word.Selection.TypeText('text'); % type text
handles.selection.MoveDown() % Move cursor downward
handles.selection.MoveLeftt(1,2,1) %Selection
handles.selction.Cells.Merge() %Merge sected celss
word.Selection.TypeText('text'); % type text
--------------------------------------------------
Any idea to generate desired output is highly appreciated.
0 Comments
Answers (1)
Wenquan
on 14 Feb 2023
Hi,you can try creating a matrix first and set the row height and column width by looping.
% Set row height, column width
column_width = [...];
row_height = [...];
for i = 1:3
DTI.Columns.Item(i).Width = column_width(i);
end
for i = 1:3
DTI.Rows.Item(i).Height = row_height(i);
end
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!