View Single Post
 
Old 10-13-2023, 04:04 AM
RobertDany RobertDany is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Jul 2021
Posts: 22
RobertDany is on a distinguished road
Default

Quote:
Originally Posted by AllekieF View Post
Modified the code a bit. Should work, but doesn't check for correct selection type.
It works perfectly
That's what I want
Thanks so much

I also googled and found this code, and also works perfectly

Code:
Sub AlignAndStretchImage()
' VBA macro to align an image in the middle and center of the slide

    Dim shp As Shape
    Set shp = ActiveWindow.Selection.ShapeRange(1)
    
        ' Set the shape's size to match the slide's size
    shp.LockAspectRatio = msoFalse
    shp.Width = ActivePresentation.PageSetup.SlideWidth
    shp.Height = ActivePresentation.PageSetup.SlideHeight
    
    ' Set the shape's position to the center of the slide
    shp.Left = (ActivePresentation.PageSetup.SlideWidth - shp.Width) / 2
    shp.Top = (ActivePresentation.PageSetup.SlideHeight - shp.Height) / 2
    

End Sub
Best Regards
Reply With Quote