Hani Simo


I am trying to write a small program to replace pictures in PowerPoint
presentation...

To find the pictures, I check Shape Type (Shape.Type = msoPicture)...

But the problem is: how can I change the picture after this step What is the method I should use to load the new picture from file to the
Shape

Best regards and have a nice day,
Hani




Re: Replacing (changing) the pictures in PowerPoint presentation

Luiz Claudio - MVP


Hi Hani,

you can try something like this:

Sub teste()

Dim Pres As Presentation
Dim Sld As Slide
Dim shp As Shape
Dim l As Single
Dim t As Single
Dim h As Single
Dim w As Single
Dim strName As String

Set Pres = ActivePresentation

Set Sld = Pres.Slides(1)

For Each shp In Sld.Shapes
If shp.Type = msoPicture Then
l = shp.Left
t = shp.Top
h = shp.Height
w = shp.Width
strName = shp.Name
shp.Delete
Set shp = Sld.Shapes.AddPicture("C:\Users\Luiz\Pictures\Caio\DSC01531.JPG", _
msoFalse, msoCTrue, l, t, w, h)
shp.Name = strName
End If
Next shp

End Sub







Re: Replacing (changing) the pictures in PowerPoint presentation

Hani Simo

Thanks Luiz,

I can imagine that, without a directly method to replace the pictureĦ­ it will be very complicated; especially if the old picture is a member in a group, has costume animation, and transparency, Z order...


Thanks again Luiz and have a nice day,
Hani