Creating tables on MS Word
64 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
I am trying to create two seperate tables and add a picture to word, but the whole document is combined into one big table. What am I do wrong in my code? Thanks!
word = actxserver('Word.Application'); %start Word
word.Visible =1; %make Word Visible
document=word.Documents.Add; %create new Document
selection=word.Selection; %set Cursor
selection.Font.Name='Times New Roman'; %set Font
selection.Font.Size=18; %set Size
selection.Pagesetup.RightMargin=50; %set right Margin
selection.Pagesetup.LeftMargin=50; %set left Margin
selection.Pagesetup.TopMargin=50; %set top Margin
selection.Pagesetup.BottomMargin=50; %set bottom Margin
selection.Paragraphs.LineUnitAfter=0.01; %sets the amount of spacing
selection.Font.Size=12;
%Creating Model input Table
word.Selection.Font.Bold = 1;
word.Selection.TypeText('Model Inputs');
word.Selection.Font.Bold = 0;
word.ActiveDocument.Tables.Add(word.Selection.Range,4,2);
word.Selection.TypeText('Equation 1');
word.Selection.MoveRight(12,1,0);
word.Selection.TypeText('y = mx+b');
word.Selection.MoveRight(12,1,0);
word.Selection.TypeText('Equation 2');
word.Selection.MoveRight(12,1,0);
word.Selection.TypeText('y = mx+b');
word.Selection.MoveRight(12,1,0);
word.Selection.TypeText('Crack Scatter Factor');
word.Selection.MoveRight(12,1,0);
word.Selection.TypeText('1');
tableObj = word.ActiveDocument.Tables.Item(1);
word.Selection.MoveRight(12,1,0);
word.Selection.TypeParagraph
%Creating Results Table
word.Selection.Font.Bold = 1;
word.Selection.TypeText('90th Percentiles');
word.Selection.MoveRight(12,1,0);
word.Selection.Font.Bold = 0;
word.Selection.TypeText('a50 @Cal');
word.Selection.MoveRight(12,1,0);
word.Selection.TypeText(num2str('50'));
word.Selection.MoveRight(12,1,0);
word.Selection.TypeText('a50 @+6dB');
word.Selection.MoveRight(12,1,0);
word.Selection.TypeText('59');
word.Selection.MoveRight(12,1,0);
word.Selection.TypeText('a50 @+12dB');
word.Selection.MoveRight(12,1,0);
word.Selection.TypeText('33');
word.Selection.TypeParagraph
tableObj.Borders.Enable = 1;
%Add figures
selection.InlineShapes.AddPicture([pwd '/Figure1.jpg'],0,1);
selection.TypeParagraph;
1 件のコメント
Srijith Sudhagar
2022 年 4 月 22 日
selection.MoveDown(5,1,1); %Break the table and switch to paragraph mode
回答 (2 件)
Kapil Gupta
2021 年 7 月 9 日
I assume you want to create tables in MS Word. The following MATLAB Answers links have similar queries, you can check these out:
0 件のコメント
Sean de Wolski
2022 年 4 月 22 日
This is exactly what the MATLAB Report Generator does really well. Look at the sections on tables and images, here:
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Tables についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!