![]() |
|
|
|
#1
|
|||
|
|||
|
If the image is placed in a placeholder, modifying the layout should have an immediate effect on all pictures. If this is not done, then try the code below. It identifies each image on all slides. resets it to the original size and crop settings (you need this as the crop size is a function of the original picture size), checks the dimensions related to the page size and resizes for this, then crops the image to fit the page and places it on the correct position. Hope this helps. Code:
Option Explicit
Sub reziseImage()
Dim J As Integer, k As Integer, m As Integer
Dim pageHeight As Integer, pageWidth As Integer
Dim cropSize As Double
pageHeight = ActivePresentation.PageSetup.SlideHeight
pageWidth = ActivePresentation.PageSetup.SlideWidth
For J = 1 To ActivePresentation.Slides.Count
For k = 1 To ActivePresentation.Slides(J).Shapes.Count
If ActivePresentation.Slides(J).Shapes(k).Type = msoPicture Then
ActivePresentation.Slides(J).Shapes(k).Select
Application.CommandBars.ExecuteMso ("PictureResetAndSize")
With ActivePresentation.Slides(J).Shapes(k)
.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
Next k
Next J
End Sub
|
|
#2
|
|||
|
|||
|
Quote:
Thank you so much for your time and efforts In most times, I use copy paste image from the internet, so there is no placeholders in most times Thanks for your code, but it works for one image, then when I apply it to the second or third image, this message appears: 37.png Dear, To clarify my need, I want to apply this code to selected image only, but not on all slides (just selected image only on the current slide). Thanks
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PowerPoint Slide Image Size / Position | revocats10 | PowerPoint | 1 | 01-23-2021 02:26 AM |
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 |
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 |