Log in

View Full Version : Import JPG Into Content Placeholder



john7
10-28-2013, 09:55 AM
Office 2010
Window 7 Pro 64bit

I have a layout which contains a content placeholder. I create a slide with this layout. My goal is to have VBA import a JPG into the content placeholder of the slide. I use a content placeholder rather than a picture placeholder because manually importing a JPG into a content placeholder does not crop while importing into a picture placeholder crops.

What is the VBA code to import a JPG into the content placeholder of a slide?

Thanks in advance.

John Wilson
10-28-2013, 12:18 PM
You need to say which version you have because 2007 acts differently to 2010 on.

john7
10-28-2013, 02:24 PM
Office 2010
Window 7 Pro 64bit

John Wilson
10-29-2013, 07:58 AM
In Office 2010 Images will usually go into empty content placeholders all by themselves.


Sub AddPic()
Dim osld As Slide
Set osld = ActivePresentation.Slides(1) ' change number to suit
'obviously adjust path to suit your image
'Left and Top will be ignored but must have a value
osld.Shapes.AddPicture "C:\Users\John\Desktop\Pic1.jpg", _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=0, _
Top:=0
End Sub

Note in 2007 this does not work.

john7
10-29-2013, 10:16 AM
This worked.
Thank you for the explanation.