-1

I need to get image ScaleWidth scaling factor and set ScaleHeight the same.

How do I get the image's height or width scaling factor?

Normally code such as this would scale with lock aspect ratio, but every time I produce a handout in PowerPoint I get very small images.

I use a macro to resize the picture, but these handout generated images do not scale with "lock aspect ratio" even if I use .LockAspectRatio = msoTrue.

I want to scale the height myself.
After I scale the width to 18.46 cm, I want to get the ScaleWidth, and set the ScaleHeight to the same number.
Ex. If ScaleWidth ends up being 145 %, then get this number and set ScaleHeight the same.

I am not able to find a solution to get ScaleHeigth, and the guide to get Height pixel/inches is not something I am able to execute in my doc.

Sub Resize_All_Images()
'
' Resize all pictures to that corresponding size
'
'
With ActiveDocument
    For I = 1 To .InlineShapes.Count
        With .InlineShapes(I)
            'the width that it will resize to'
            .Width = CentimetersToPoints(18.46)
        End With
    Next I
End With
End Sub
Community
  • 1
  • 1
user53617
  • 33
  • 4
  • from PP, to every one, i use 18.46 cm since i use margin = narrow. i use a macro for this. now i can get pictures in pages with lock aspect ratio and all pictures set to max possible width, thx to @Timothy Rylatt – user53617 Sep 06 '22 at 13:25

1 Answers1

0

Try this:

Sub Resize_All_Images()
    '
    ' Resize all pictures to that corresponding size
    '
    '
    Dim NewWidth As Long: NewWidth = CentimetersToPoints(18.46)
    Dim ils As InlineShape
    With ActiveDocument
        For Each ils In .InlineShapes
            With ils
                'the width that it will resize to'
                .Height = (.Height / .Width) * NewWidth
                .Width = NewWidth
                .LockAspectRatio = msoTrue
            End With
        Next ils
    End With
End Sub
Timothy Rylatt
  • 7,221
  • 2
  • 10
  • 14
  • Awesome works like a charm, i had been trying you math solution for Height, that i found another one talk about, but i could not get it to work, i must have been on the right track then. instead i focused on get Scale-factor. but this is better, shorter, simple. @Timothy Rylatt great job THX so much – user53617 Sep 06 '22 at 13:21