Crop MS Word Images using Matlab Activex control

后端 未结 1 1573
失恋的感觉
失恋的感觉 2020-12-22 12:25

I am using MATLAB to paste and caption plots into Microsoft Word. I would like to also crop these images using the ActiveX control.

something like:

         


        
相关标签:
1条回答
  • 2020-12-22 13:26

    Consider this example:

    %# 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 讨论(0)
提交回复
热议问题