使用Matlab Activex控件裁剪MS Word图像

时间:2011-09-30 23:43:20

标签: matlab ms-word activex office-interop

我正在使用MATLAB将图表粘贴并添加到Microsoft Word中。我还想使用ActiveX控件裁剪这些图像。

类似的东西:

word = actxserver('Word.Application')

word.Visible = 1
op = invoke(word.Documents,'Add')

invoke(word.Selection,'Paste')

invoke(word.Selection,'CropBottom',CropAmount) <----- Except there is no function that will allow me to crop.

我正在修改MATLAB文件交换"save2word.m"

由于

1 个答案:

答案 0 :(得分:0)

考虑这个例子:

%# create plot and copy to clipboard
plot(rand(10,1))
print -dmeta

%# open MS-Word
Word = actxserver('Word.Application');
Word.Visible = true;

%# create new document
doc = Word.Documents.Add;

%# paste figure from clipboard
Word.Selection.Paste

%# crop the image
doc.InlineShapes.Item(1).PictureFormat.CropBottom = 100;

%# save document, then close
doc.SaveAs2( fullfile(pwd,'file.docx') )
doc.Close(false)

%# quit and cleanup
Word.Quit
Word.delete

screenshot_ms_word