2011-09-30 58 views
0

我正在使用MATLAB将图标粘贴到Microsoft Word中。我想也使用ActiveX控件裁剪这些图像。使用Matlab Activex控件裁剪MS Word图像

类似:

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"

感谢

回答

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

+0

非常感谢你的帮助。 – user973995