Create a word document from Matlab

上一篇主題 下一篇主題 向下

Create a word document from Matlab

發表 由 lung 于 周三 五月 15, 2013 10:53 am

avatar
lung
Admin

文章數 : 9469
注冊日期 : 2009-07-12

檢視會員個人資料

回頂端 向下

回復: Create a word document from Matlab

發表 由 lung 于 周三 五月 15, 2013 10:55 am

Create the word application

and make it visible

word = actxserver('Word.Application');
word.Visible = 1;

Add a new document and get the current selection

document = word.Documents.Add;
selection = word.Selection;

add text and paragraphs

selection.TypeText('Hello world. ');
selection.TypeText('My name is Professor Kitchin');
selection.TypeParagraph;
selection.TypeText('How are you today?');
selection.TypeParagraph;

Setting a Header

selection.TypeText('Big Finale');
selection.Style='Heading 1';
selection.TypeParagraph;

Modifying Header properties

H1 = document.Styles.Item('Heading 1')
H1.Font.Name = 'Garamond';
H1.Font.Size = 20;
H1.Font.Bold = 1;
H1.Font.TextColor.RGB=60000; % some ugly color green

selection.TypeParagraph
selection.TypeText('That is all for today!')


H1 =

Interface.0002092C_0000_0000_C000_000000000046

Now we save the document

document.SaveAs2([pwd '/test.docx']);
word.Quit();
avatar
lung
Admin

文章數 : 9469
注冊日期 : 2009-07-12

檢視會員個人資料

回頂端 向下

上一篇主題 下一篇主題 回頂端

- 相似主題

 
這個論壇的權限:
無法 在這個版面回復文章