Changing Captions in Word using Matlab

10 次查看(过去 30 天)
Mitra
Mitra 2013-1-9
回答: Dave! 2019-10-5
Hello All,
1. Does any one know how to change the Font and Size of the caption to tables in word using Matlab commands?
I use
actx_Report = actxserver('Word.Application');
actx_Report.ActiveDocument.Tables.Add(actx_Report.Selection.Range,5,7,1,1);
to generate the table.
and
actx_Report.Selection.InsertCaption('Table', [' : Absolute Mean Error', num2str(j)], '', 0, false);
to insert captions.

回答(1 个)

Dave!
Dave! 2019-10-5
Hello,
I know this is an older question, but here is a workaround that I have found handy.
Since you have access to the Styles of a document, I find it easier to create an absolutely empty file that has all Styles in it that I want. For instance, I set the Caption style to be bold, centered, non-italics, and the font size that I want. When I want to create a new Word file from MATLAB, I simply make a copy of my template file and open that rather than open a brand new document that will be of Word's default template style.
Then, when I actxserver.Selection.InsertCaption, it is already formatted how I want.
Word also has a set of Table styles that you can apply:
tbl = actXObj.ActiveDocument.Tables.Add(actXObj.Selection.Range, nRows, nCols, 1, 1);
tbl.ApplyStyleDirectFormatting('NameOfCustomTableStyle');

类别

Help CenterFile Exchange 中查找有关 MATLAB Report Generator 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by