Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 10-13-2023, 03:21 AM
AllekieF AllekieF is offline Macro to make image fit to slide exactly in PowerPoint Windows 10 Macro to make image fit to slide exactly in PowerPoint Office 2021
Novice
 
Join Date: Oct 2023
Location: Netherlands
Posts: 9
AllekieF is on a distinguished road
Default

Modified the code a bit. Should work, but doesn't check for correct selection type.

Code:
Option Explicit

Sub reziseImage()
Dim pageHeight As Integer, pageWidth As Integer
Dim cropSize As Double

pageHeight = ActivePresentation.PageSetup.SlideHeight
pageWidth = ActivePresentation.PageSetup.SlideWidth

If ActiveWindow.Selection.Type = ppSelectionShapes Then
    Application.CommandBars.ExecuteMso ("PictureResetAndSize")
    With ActiveWindow.Selection.ShapeRange
        .LockAspectRatio = True
        If .Height / .Width > pageHeight / pageWidth Then
            cropSize = (pageWidth / .Width * .Height - pageHeight) / (pageWidth / .Width) / 2
            .Width = pageWidth
            .PictureFormat.CropTop = cropSize
            .PictureFormat.CropBottom = cropSize
        Else
            cropSize = (pageHeight / .Height * .Width - pageWidth) / (pageHeight / .Height) / 2
            .Height = pageHeight
            .PictureFormat.CropLeft = cropSize
            .PictureFormat.CropRight = cropSize
        End If
        .Left = 0
        .Top = 0
    End With
End If
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
PowerPoint Slide Image Size / Position revocats10 PowerPoint 1 01-23-2021 02:26 AM
Macro to make image fit to slide exactly in PowerPoint VBS script to make PowerPoint's default slide size to 16:9 from 4:3. jr13 PowerPoint 1 03-21-2015 04:34 AM
How to make specific slide be unlike the master slide Konnie PowerPoint 4 11-03-2014 05:16 AM
Macro to make image fit to slide exactly in PowerPoint Saving as ( PowerPoint Macro-Enabled Slide Show )?? delete123 PowerPoint 2 04-10-2013 05:38 AM
URGENT!!! Powerpoint Image Formatting and Positioning Macro mertulufi PowerPoint 5 12-20-2011 10:14 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:42 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft