mzage
mzage

Reputation: 378

how to do something in all slides by just one code?

i use this code and you can see it just work for slide 1 :

 Sub o_c_LTab(shape As shape)

Lt = ActivePresentation.Slides(1).Shapes("LT").Left
If Lt = -175 Then
    Do
    DoEvents
    Lt = Lt + 25
        ActivePresentation.Slides(1).Shapes("LT").Left = Lt
        ActivePresentation.Slides(1).Shapes("LT_handle").Left = ActivePresentation.Slides(1).Shapes("LT_handle").Left + 25
        ActivePresentation.Slides(1).Shapes("1").Left = ActivePresentation.Slides(1).Shapes("1").Left + 25
        ActivePresentation.Slides(1).Shapes("2").Left = ActivePresentation.Slides(1).Shapes("2").Left + 25
        ActivePresentation.Slides(1).Shapes("3").Left = ActivePresentation.Slides(1).Shapes("3").Left + 25
        ActivePresentation.Slides(1).Shapes("4").Left = ActivePresentation.Slides(1).Shapes("4").Left + 25
        ActivePresentation.Slides(1).Shapes("5").Left = ActivePresentation.Slides(1).Shapes("5").Left + 25

    timeout (0.01)
    Loop Until Lt = 0
ElseIf Lt = 0 Then
    Do
    DoEvents
    Lt = Lt - 25
        ActivePresentation.Slides(1).Shapes("LT").Left = Lt
        ActivePresentation.Slides(1).Shapes("LT_handle").Left = ActivePresentation.Slides(1).Shapes("LT_handle").Left - 25
        ActivePresentation.Slides(1).Shapes("1").Left = ActivePresentation.Slides(1).Shapes("1").Left - 25
        ActivePresentation.Slides(1).Shapes("2").Left = ActivePresentation.Slides(1).Shapes("2").Left - 25
        ActivePresentation.Slides(1).Shapes("3").Left = ActivePresentation.Slides(1).Shapes("3").Left - 25
        ActivePresentation.Slides(1).Shapes("4").Left = ActivePresentation.Slides(1).Shapes("4").Left - 25
        ActivePresentation.Slides(1).Shapes("5").Left = ActivePresentation.Slides(1).Shapes("5").Left - 25
    timeout (0.01)
    Loop Until Lt = -175
End If

End Sub


Sub timeout(duration_ms As Double)
    Start_Time = Timer
    Do
    DoEvents
    Loop Until (Timer - Start_Time) >= duration_ms
End Sub

i have this shapes in 200 slides and i should write this for 200 times , how can i do that in all slides by just one code?

Upvotes: 2

Views: 48

Answers (1)

Darren Bartrup-Cook
Darren Bartrup-Cook

Reputation: 19857

Each Slide will be an item in the Slides collection. You can step through each item in a collection using:

Sub Test()

    Dim sl As Slide

    For Each sl In ActivePresentation.Slides
        Debug.Print sl.Name
    Next sl

End Sub

Then rather than use ActivePresentation.Slides(1).Shapes("LT") you can use sl.Shapes("LT")

Upvotes: 2

Related Questions