Macro to resize a picture

S

simonc

There doesn't seem to be a dedicated Powerpoint macro user group, so
hopefully someone here will know this:

I recorded a macro in which I selected a picture and resized it to 65% using
Picture Format>Size. However, when I looked at the macro in VBA editor it had
used the picture Width and Height properties and set these to an exact number
of pixels.

With ActiveWindow.Selection.ShapeRange
.Height = 437.25
.Width = 592.25
End With

So my macro will only produce the 65% reduction for a picture of exactly the
same size as the one I used to record it.

There are methods called ScaleWidth and ScaleHeight in the help but I can't
seem to get the syntax right for using these. If I put

With ActiveWindow.Selection.ShapeRange
.ScaleHeight = 0.65
End With

I get "Compile Error Argument not optional".

Can someone tell me what this means and how to correct it?

Many thanks
 
T

tohlz

*Hint: record macro, select two pictures instead of one.*
See if this works:

Sub resize()
With ActiveWindow.Selection.ShapeRange
.ScaleHeight 0.65, msoFalse, msoScaleFromTopLeft
.ScaleWidth 0.65, msoFalse, msoScaleFromTopLeft
End With
End Sub

--
Microsoft Most Valuable Professional (MVP PowerPoint)

Site Updated: April 13, 2006
Added new portfolio
http://pptheaven.mvps.org
PowerPoint Heaven - The Power to Animate
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top