Changing Captions in Word using Matlab

조회 수: 15 (최근 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