Graphic Sizing in PowerPoint

C

Coogrr

In the Format picture dialog box there are several options. One option
allows you to lock the aspect ratio and another allows you to set the
size of the picture as a percentage of the selected picture (i.e., by
selecting 90% the picture is reduced to 90% of its original size).

I want to write a macro that will reduce any selected picture by a set
percentage while locking the aspect ratio. I tried recording a macro
but PowerPoint automatically converts the percentage to a fixed
dimension and does not show how the percentage was acted upon.

I have scoured my VBA and VBA Net reference books and can not find any
information relating to this.

Thanks,

Dennis
 
S

Steve Rindsberg

Coogrr said:
In the Format picture dialog box there are several options. One option
allows you to lock the aspect ratio and another allows you to set the
size of the picture as a percentage of the selected picture (i.e., by
selecting 90% the picture is reduced to 90% of its original size).

I want to write a macro that will reduce any selected picture by a set
percentage while locking the aspect ratio. I tried recording a macro
but PowerPoint automatically converts the percentage to a fixed
dimension and does not show how the percentage was acted upon.

The percentage display is a user-friendly feature in the dialog box but there
are no methods that use it. You'll have to do your own arithmetic if you want
to work in percentages.
 
C

Coogrr

Steve,

I kept searching and found the Scale properties. So the following code
does what I want:

Public iSize as Variant
--------------------------------------------------
Have user input iSize as percentage
-------------------------------------------------------
Sub

iSize = iSize/100
With ActiveWindow.Selection.ShapeRange
.ScaleWidth iSize, msoTrue
.ScaleHeight iSize, msoTrue
End With

End Sub
 
S

Steve Rindsberg

Coogrr said:
Steve,

I kept searching and found the Scale properties. So the following code
does what I want:

Public iSize as Variant
--------------------------------------------------
Have user input iSize as percentage
-------------------------------------------------------
Sub

iSize = iSize/100
With ActiveWindow.Selection.ShapeRange
.ScaleWidth iSize, msoTrue
.ScaleHeight iSize, msoTrue
End With

End Sub


Bingo. I mentioned that you'd need to do your own arithmetic. Forgot to
mention that it was no more complex than your iSize/100 ;-)

Note that you can also do this:

With oSh
.LockAspectRatio = True
Msgbox .Width
.Height = .Height / 2 ' or any other adjustment to size
Msgbox .Width
End With

IOW, when .LockAspectRatio is true, adjustments to one dimension will be
automatically applied to the other so that the proportions of the shape don't
change.
 

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