MATLAB: Creating Tables in word using actxserver

activex serverMATLABMATLAB Report Generatormatlabtowordmicrosoft word

please can someone help me ? i have the following code i want to create tables in word but i have the following result. .i will like to have the Table grids thanks
clear all;
word = actxserver('Word.Application');
word.Visible = true;
wdoc = word.Documents.Add;
selection = word.Selection;
word.ActiveDocument.Tables.Add(word.Selection.Range,4,2);
word.Selection.Font.Bold = 1;
word.Selection.TypeText('gender');
word.Selection.MoveRight(12,1,0);
word.Selection.Font.Bold = 1;
word.Selection.TypeText('Name');
word.Selection.MoveRight(12,1,0);
word.Selection.TypeText('Female');
word.Selection.MoveRight(12,1,0);
word.Selection.TypeText('Lucy');
word.Selection.MoveRight(12,1,0);
word.Selection.TypeText('male');
word.Selection.MoveRight(12,1,0);
word.Selection.TypeText('Leo');
word.Selection.MoveRight(12,1,0);
word.Quit();
this is what i get!

Best Answer

Hello,
These two lines add the borders to your table.
tableObj = word.ActiveDocument.Tables.Item(1);
tableObj.Borders.Enable = 1;