Word vba how to save picture from image object to file?

耗尽温柔 提交于 2019-12-13 07:50:06

问题


I have an image object on a userform. I want to save the picture from that image object into a file. I see many examples of how to load a picture into an image object, but none the other way around.

I tried stdole.SavePicture obj.Picture, strFilePath, but that only works for button objects.


回答1:


First create a Chart. Second place the picture in the Chart. Finally export the Chart.

EDIT#1

For sample code see:

Save Picture with VBA




回答2:


I don't know if this will help, but I tried casting the Picture object to an IPictureDisp object to pass it to the stdoleSavePicture function, and it worked for me.

Here's the code:

Dim pic As IPictureDisp

Set pic = myForm.Image1.Picture

stdole.SavePicture pic, "C:\myfile.jpg"


来源:https://stackoverflow.com/questions/31922261/word-vba-how-to-save-picture-from-image-object-to-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!