Change the image of an image shape

僤鯓⒐⒋嵵緔 提交于 2019-12-08 01:56:20

问题


I want to be able to change the image of an image shape by clicking on an button in my userform.

In the internet I found the function UserPicture, but the image simply stays the same.

Private Sub ChangeImage_Click()
    ActivePresentation.Slides("Slide1").Shapes("SolutionA_Image").Visible = True

    ActivePresentation.Slides("Slide1").Shapes("SolutionA_Image").Fill.UserPicture ("D:\User\Desktop\SolutionWrong.jpg")
End Sub

Private Sub HideImage_Click()
    ActivePresentation.Slides("Slide1").Shapes("SolutionA_Image").Visible = False
End Sub

When I click on the HideImage button, the shape becomes invisible, so my selection of the shape appears to be right.

I also tried

ActivePresentation.Slides("Slide1").Shapes("SolutionA_Image").Fill.UserPicture "D:\User\SolutionWrong.jpg"

but this does not work either

Edit
Of course I checked the path to the new image, it's correct.


回答1:


Siddharth Rout found the solution

I created the image by selecting picture from the insert menu, but it have to be created via Insert => Rectangular shape (no border). Now it can easily be accessed by using ActivePresentation.Slides("Slide1").Shapes("SolutionA_Image").Fill.UserPicture ("D:\User\SolutionWrong.jpg")



来源:https://stackoverflow.com/questions/14503054/change-the-image-of-an-image-shape

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