Reputation: 47
I want to move everything on a slide a set distance (inches) in one direction. For example, everything on slide 1 (odd) slides I want to move 1 inch to the right and slide 2 (even) slides 1 inch to the left. With this repeated throughout the presentation. Is this possible? I've sort of worked this out so far but it doesn't work... Thanks, Jay
Sub Button10()
Dim i As Long
With ActivePresentation.Slides
For i = 1 To .count
If i Mod 2 = 1 Then
MoveRight
End If
If i Mod 2 = 2 Then
MoveLeft
End If
Next i
End With
MsgBox "Completed!", vbExclamation
End Sub
Sub MoveRight()
Dim i As Long
With ActivePresentation
For Each Slide In .Slides
For Each Shape In Slide.Shapes
With Shape
Shape.Left = Shape.Left + (1.5 * 72)
End With
Next
Next
End With
End Sub
Sub MoveLeft()
With ActivePresentation
For Each Slide In .Slides
For Each Shape In Slide.Shapes
With Shape
Shape.Left = Shape.Left - (1.5 * 72)
End With
Next
Next
End With
End Sub
Upvotes: 0
Views: 171
Reputation: 4923
This code will do that. The Mod operator divides the slide index number by 2 and returns the remainder. When the remainder is 1, it's an odd numbered slide, when the remainder is 0 it's even:
Sub MoveShapes()
Dim oSlide As Slide
Dim oShape As Shape
For Each oSlide In ActivePresentation.Slides
If oSlide.SlideIndex Mod 2 = 1 Then 'Odd numbered slide
For Each oShape In oSlide.Shapes
oShape.Left = oShape.Left + 72
Next oShape
Else
For Each oShape In oSlide.Shapes
oShape.Left = oShape.Left - 72
Next oShape
End If
Next oSlide
End Sub
Upvotes: 3