Matlab 创建word文档,网上都可以查询到相关的资料,但是怎么通过matlab插入图片后,在图片下方插入题注及图片说明,我查了相关的资料不太容易查询到,特别写这么一篇文章,和大家共同学习。
clc;clear;close all;fclose all;
picpath=[pwd,'\pic\'];
filespec_user = [pwd '\附件1.doc'];% 设定测试Word文件名和路径
if exist(filespec_user,'file')
delete(filespec_user);
end
% 判断Word是否已经打开,若已打开,就在打开的Word中进行操作,否则就打开Word
try
% 若Word服务器已经打开,返回其句柄Word
Word = actxGetRunningServer('Word.Application');
catch
% 否则,创建一个Microsoft Word服务器,返回句柄Word
Word = actxserver('Word.Application');
end
Word.Visible = 0; % 或set(Word, 'Visible', 1);
Document = Word.Documents.Add;
Document.SaveAs2(filespec_user);
Content = Document.Content;
Selection = Word.Selection;
Word.CaptionLabels.Add('图') ;%题注
Word.CaptionLabels.Add('表');
Word.Selection.InsertCaption('表', '时域汇总表', '', 0, false);
T