Create a word document from Matlab
winggundam :: all :: 電腦知識
第1頁(共1頁)
回復: Create a word document from Matlab
Create the word application
and make it visible
Add a new document and get the current selection
add text and paragraphs
Setting a Header
Modifying Header properties
Now we save the document
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- Admin
- 文章數 : 26067
注冊日期 : 2009-07-12
winggundam :: all :: 電腦知識
第1頁(共1頁)
這個論壇的權限:
您 無法 在這個版面回復文章