Changing Captions in Word using Matlab
14 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Dave!
on 5 Oct 2019
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');
0 Comments
See Also
Categories
Find more on MATLAB Report Generator in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!