Results 1 to 1 of 1
2011-10-12, 15:51 #1
- Join Date
- Sep 2006
- New York, New York, USA
- Thanked 0 Times in 0 Posts
PPT 2010: Setting "Fit" For Crop PictureFormat Property (VBA)
I want to use VBA to load an image into a picture placeholder, with the image's aspect ratio maintained and the entire image fit into the placeholder (of course, asymmetric images would have one dimension -- height or width -- padded with a margin). The placeholder's size needs to remain fixed.
I found the "Fit" setting for the Crop tool in the Picture Tools ribbon. If I select "Fit" after manually inserting the picture into the placeholder, it does exactly what I want -- resizes the image so that at least one dimension (height or width) is sized to the limit of the placeholder while maintaining the aspect ratio for the other dimension. The image is not stretched, and is centered within the placeholder either vertically or horizontally (depending on which dimension has the margins).
I want to replicate the above functionality in VBA, but don't understand how to load a picture from a file into an existing placeholder (although, I see how to do this with a generic shape, but is not what I want). I also can't find how to select the "Fit" setting for cropping. I experimented with the 4 Crop properties (CropBottom, etc.) of the PictureFormat object, but while it does remove the cropping, it also resizes the image larger than the original placeholder's size and I don't see how to set the image to "Fit".
Can anyone provide me with a few lines of VBA code to handle the above? Incidentally, I need to support VBA for PPT 2010, 2007, and possibly 2003.
Thanks very much for any assistance that you can provide!