Reputation: 2057
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.
Upvotes: 2
Views: 6174
Reputation: 2057
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")
Upvotes: 2