PDA

View Full Version : How do I run macros on any slide with a selected shape?



Walley
04-10-2011, 12:37 PM
I'm very new to VBA. I can't seem to find out how to run macros on a selected shape on any slide. I eventually want to take the code below and create a button for it.

What I want to accomplish:
1. I insert in a jpg for my slide
2. With the jpg selected, I want to click a button and automatically have it resize. I want to be able to resize any jpg/shape that I click and select on any slide.

Thanks for the help.


Sub imageResize()
With ActivePresentation.Slides(1).Shapes(1)
' Disable Lock Aspect Ratio
.LockAspectRatio = msoFalse
' Scale 100% of original height and width (Will not uncheck RelativeToOriginalSize box or update percentage)
.ScaleHeight 1, msoFalse
.ScaleWidth 1, msoFalse
.PictureFormat.CropBottom = 6
' Width 7.5"
.Width = 720
' Height 10"
.Height = 540
' Position image at xy = 0
.Left = 0
.Top = 0
End With
End Sub

John Wilson
04-17-2011, 01:18 PM
Sub imageResize()
With ActiveWindow.Selection.ShapeRange(1)
' Disable Lock Aspect Ratio
.LockAspectRatio = msoFalse ' Scale 100% of original height and width (Will not uncheck RelativeToOriginalSize box or update percentage) .ScaleHeight 1, msoFalse
.ScaleWidth 1, msoFalse
.PictureFormat.CropBottom = 6
' Width 7.5"
.Width = 720
' Height 10"
.Height = 540
' Position image at xy = 0
.Left = 0
.Top = 0
End With
End Sub