matlab命令打开Word文档
本博文源于Matlab骚操作系列,旨在讲述文档打开操作。首先要保证自己有Word。然后我们开始实验。
·
本博文源于Matlab骚操作系列,旨在讲述文档打开操作。首先要保证自己有Word。然后我们开始实验。
实验步骤
- 创建Word服务器
- 设置Word服务器可见
- 新建空白文档
- 写入文档内容
- 保存文档
实验内容
创建word服务器
>> try
Word = actxGetRunningServer('Word.Application')
catch
Word = actxserver('Word.Application')
end;
Word =
COM.Word_Application
设置服务器可见
>> set(Word,'Visible',1)
新建空白文档
>> Document = Word.Documents.Add;
书写内容
>> Content = Document.Content;
>> Content.Start = 0;
>> title = '试 卷 分 析';
>> Content.Text = title;
>> Content.Font.Size = 16;
>> Content.Font.Bold = 4;
>> Content.Paragraphs.Alignment = 'wdAlignParagraphCenter';
保存内容
>> Word.Documents.Save;
实验效果
实验完整代码
>> try
Word = actxGetRunningServer('Word.Application')
catch
Word = actxserver('Word.Application')
end;
Word =
COM.Word_Application
>> set(Word,'Visible',1)
>> Document = Word.Documents.Add;
>> Content = Document.Content;
Content.Start = 0;
title = '试 卷 分 析';
Content.Text = title;
Content.Font.Size = 16;
Content.Font.Bold = 4;
>> Content.Paragraphs.Alignment = 'wdAlignParagraphCenter';
>> Word.Documents.Save;
>>
更多推荐
所有评论(0)