winggundam
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Create a word document from Matlab

向下

Create a word document from Matlab Empty Create a word document from Matlab

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

lung
lung
Admin

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

回頂端 向下

Create a word document from Matlab Empty 回復: 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();
lung
lung
Admin

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

回頂端 向下

回頂端


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