Share via

VBA Resize and Repostion Multiple pictures in Powerpoint

Anonymous
2021-04-15T20:10:28+00:00

I don't have much background in programming or VBA but I've had some success so far, just can't figure out how to do exactly what I want. We create 2 slides for each sample we make. Each slide has data and images that are copied and pasted from other files. We have sets of pictures we copy and paste, one has 6 images, so I want to be able to resize, reposition and send them to back. I've figured out how to do it on individual images. Click one then run a macro, click the next run the next macro. Etc. I want to be able to run them all at once and haven't been able to figure it out. Any help would be greatly appreciated! Here's what I've been using. 

'this macro is used to resize, reposition and send to back DLS CF (correlation function) graphs for developability slide decks

Sub DLS_CF()

With ActiveWindow.Selection.ShapeRange

    'whatever window is actively selected will turn lock aspect ratio to on before resizing and positioning

        .LockAspectRatio = msoTrue

        'DLS CF Graph is 2.49"Hx3.33"W, lock aspect ratio on, Horizontal position 6.66" from top left corner and Vertical position 0" from top left corner. Value converted from inches to points

        .Height = 179.28

        .Left = 479.52

        .Top = 0

    End With

    'sends selected window to back

    ActiveWindow.Selection.ShapeRange.ZOrder msoSendToBack

End Sub

'this macro is used to resize, reposition and send to back DLS MD (mass distribution) graphs for developability slide decks

Sub DLS_MD()

With ActiveWindow.Selection.ShapeRange

    'whatever window is actively selected will turn lock aspect ratio to on before resizing and positioning

        .LockAspectRatio = msoTrue

        'DLS MD Graph is 2.49"Hx3.33"W, lock aspect ratio on, Horizontal position 6.66" from top left corner and Vertical position 2.51” from top left corner. Value converted from inches to points

        .Height = 179.28

        .Left = 479.52

        .Top = 180.72

    End With

    'sends selected window to back

    ActiveWindow.Selection.ShapeRange.ZOrder msoSendToBack

End Sub

'this macro is used to resize, reposition and send to back DLS ID (Intensity distribution) graphs for developability slide decks

Sub DLS_ID()

With ActiveWindow.Selection.ShapeRange

    'whatever window is actively selected will turn lock aspect ratio to on before resizing and positioning

        .LockAspectRatio = msoTrue

        'DLS ID Graph is 2.49"Hx3.33"W, lock aspect ratio on, Horizontal position 6.66" from top left corner and Vertical position 5.01” from top left corner. Value converted from inches to points

        .Height = 179.28

        .Left = 479.52

        .Top = 360.72

    End With

    'sends selected window to back

    ActiveWindow.Selection.ShapeRange.ZOrder msoSendToBack

End Sub

'this macro is used to resize, reposition and send to back Tm (melting temp) graphs for developability slide decks

Sub Tm()

With ActiveWindow.Selection.ShapeRange

    'whatever window is actively selected will turn lock aspect ratio to on before resizing and positioning

        .LockAspectRatio = msoTrue

        'Tm Graph is 2.49"Hx3.33"W, lock aspect ratio on, Horizontal position 10” from top left corner and Vertical position 0” from top left corner. Value converted from inches to points

        .Height = 179.28

        .Left = 720

        .Top = 0

    End With

    'sends selected window to back

    ActiveWindow.Selection.ShapeRange.ZOrder msoSendToBack

End Sub

'this macro is used to resize, reposition and send to back Tagg 266 (aggregation temp @ 266 nm ) graphs for developability slide decks

Sub Tagg_266()

With ActiveWindow.Selection.ShapeRange

    'whatever window is actively selected will turn lock aspect ratio to on before resizing and positioning

        .LockAspectRatio = msoTrue

        'Tagg 266 Graph is 2.49"Hx3.33"W, lock aspect ratio on, Horizontal position 10” from top left corner and Vertical position 2.51” from top left corner. Value converted from inches to points

        .Height = 179.28

        .Left = 720

        .Top = 180.72

    End With

    'sends selected window to back

    ActiveWindow.Selection.ShapeRange.ZOrder msoSendToBack

End Sub

'this macro is used to resize, reposition and send to back Tagg 473 (aggregation temp @ 473 nm ) graphs for developability slide decks

Sub Tagg_473()

With ActiveWindow.Selection.ShapeRange

    'whatever window is actively selected will turn lock aspect ratio to on before resizing and positioning

        .LockAspectRatio = msoTrue

        'Tagg 473 Graph is 2.49"Hx3.33"W, lock aspect ratio on, Horizontal position 10” from top left corner and Vertical position 5.01” from top left corner. Value converted from inches to points

        .Height = 179.28

        .Left = 720

        .Top = 360.72

    End With

    'sends selected window to back

    ActiveWindow.Selection.ShapeRange.ZOrder msoSendToBack

End Sub

Microsoft 365 and Office | PowerPoint | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2021-04-16T10:31:06+00:00

Your values do not work for me but something based on this

Sub DLS_CF()

    Dim oshpR  As ShapeRange

    Dim oshp   As Shape

    Dim lngCount As Long

    Set oshpR = ActiveWindow.Selection.ShapeRange

    For lngCount = oshpR.Count To 1 Step -1

        Set oshp = oshpR(lngCount)

        With oshp

            .LockAspectRatio = msoTrue

            Select Case lngCount

            Case Is = 1

                .Height = 179.28

                .Left = 479.52

                .Top = 0

            Case Is = 2

                .Height = 179.28

                .Left = 720

                .Top = 0

            Case Is = 3

                .Height = 179.28

                .Left = 479.52

                .Top = 180.72

            Case Is = 4

                .Height = 179.28

                .Left = 720

                .Top = 180.72

            Case Is = 5

                .Height = 179.28

                .Left = 479.52

                .Top = 360.72

            Case Is = 6

                .Height = 179.28

                .Left = 720

                .Top = 360.72

            End Select

        End With

    Next

End Sub

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2021-04-16T17:08:12+00:00

    That worked! Thank you so much!!

    Was this answer helpful?

    0 comments No comments