You are on page 1of 3

Sub fix_Album()

Dim oShp As Shape

Dim oshp2 As Shape

Dim oSld As Slide

Dim lTotal As Long, lCount As Long

Dim SldW As Single, SldH As Single

Const SHP_HEIGHT = 72 * 4.9

Const SHP_WIDTH = 72 * 6.17

With ActivePresentation.PageSetup

SldH = .SlideHeight

SldW = .SlideWidth

End With

For Each oSld In ActivePresentation.Slides

' Get the total number of pictures for this slide

lTotal = GetPictureCount(oSld)

For Each oShp In oSld.Shapes

If oShp.Type = msoPicture Then

lCount = lCount + 1

With oShp

.LockAspectRatio = False

Select Case lTotal

Case Is = 1 ' One picture : align centre

oShp.Height = 72 * 5.4

oShp.Width = 72 * 9.77

oShp.Left = SldW / 2 - oShp.Width / 2

oShp.Top = SldH / 2 - 170


oShp.Line.Weight = 3
oShp.Line.Style = msoLineSingle
oShp.Line.ForeColor.RGB = RGB(0, 0, 0)

Case Is = 2

' Picture 1
If lCount = 1 Then

oShp.Height = 72 * 4.4

oShp.Width = 72 * 6.17

oShp.Left = 30

oShp.Top = SldH / 8 + 50

oShp.Line.Weight = 3
oShp.Line.Style = msoLineSingle
oShp.Line.ForeColor.RGB = RGB(0, 0, 0)

' Picture 2

ElseIf lCount = 2 Then

oShp.Height = 72 * 4.4

oShp.Width = 72 * 6.17

oShp.Left = SldW / 2 + 15

oShp.Top = SldH / 8 + 50
oShp.Line.Weight = 3
oShp.Line.Style = msoLineSingle
oShp.Line.ForeColor.RGB = RGB(0, 0, 0)
End If

Case Else

Debug.Print lTotal & " picture(s) found on slide " & oSld.SlideIndex

End Select

End With

End If

Next

lCount = 0

Next

End Sub

Function GetPictureCount(oSld As Slide) As Long

Dim oShp As Shape

Dim lCount As Long

For Each oShp In oSld.Shapes


Select Case oShp.Type
Case msoPicture

lCount = lCount + 1

Case msoPlaceholder

If oShp.PlaceholderFormat.ContainedType = msoPicture Then _

lCount = lCount + 1
End If

End Select

Next

GetPictureCount = lCount

End Function

You might also like