View Single Post
 
Old 12-05-2023, 10:41 PM
laith93 laith93 is offline Windows 10 Office 2019
Competent Performer
 
Join Date: Jul 2021
Posts: 117
laith93 is on a distinguished road
Default Make shapes autofit to slide width

Hi,
With this code, you can autofit shapes to fit slide width, but it requires to put your dimension (Left, width), which may be not suitable when changing your slide size, it will require setting a new dimension
So how to make shapes autofit slide width without setting the dimension each time?
Thanks

Code:
Sub TextBoxAutoFitWidth4All()

  'set the variables
  Set pst = ActivePresentation
  
  'start the loops
  For Each osld In pst.Slides
    For Each oshp In osld.Shapes
      pass = 1
      'check if we want to skip the shape
      If oshp.HasTextFrame = msoFalse Then pass = 0
      'we can add as many as we want here in case there is more criteria needed
      If pass = 1 Then
        With oshp
          .LockAspectRatio = False
          .Left = 15
          .Width = 900

        End With
      End If
    Next oshp
  Next osld
End Sub
Reply With Quote