Consulting

Results 1 to 8 of 8

Thread: PowerPoint VBA prematurely exit loop slide show

  1. #1

    PowerPoint VBA prematurely exit loop slide show

    If a textbox with the name "Textbox1" is present on a current slide a counter wil start.

    But only when the counter has stopped you can navigate to another slide. How can i cancel prematurely the loop so i can navigate to another slide?


    Public
    Sub OnSlideShowPageChange(ByVal Wn As SlideShowWindow)

    Dim t AsDate
    Dim s As Shape

    ForEach s In Wn.View.Slide.Shapes

    If s.Name ="Textbox1"Then

    t
    = DateAdd("s",10, Now())

    DoUntil t < Now()

    DoEvents

    Wn
    .View.Slide.Shapes("Textbox1").TextFrame.TextRange.Text = Timer

    Loop

    EndIf

    Next s

    EndSub

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    1,864
    Location
    Not sure why you would do this but here's one way

    Dim B_Stop As Boolean
    
    Sub OnSlideShowPageChange(ByVal Wn As SlideShowWindow)
    
    
    Dim t As Date
    Dim s As Shape
    B_Stop = False
    For Each s In Wn.View.Slide.Shapes
    If s.Name = "TextBox1" Then
    t = DateAdd("s", 10, Now())
    Do Until t < Now()
    If B_Stop = True Then Exit Do
    DoEvents
    Wn.View.Slide.Shapes("TextBox1").TextFrame.TextRange.Text = Timer
    Loop
    End If
    Next s
    End Sub
    
    
    Sub stopper()
    ' have a button to run this
    B_Stop = True
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    i don't want to use a button. i'm looking for a way to navigate true slides (next/previous) without buttons.

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    1,864
    Location
    There's no way I know to jump out of the loop without a button.

    BUT what is the purpose of the loop, Maybe you just do not need it.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    why is the event OnSlideShowPageChange not responding during the loop? I really need the loop....

  6. #6
    VBAX Master
    Joined
    Feb 2007
    Posts
    1,864
    Location
    Why would it. There is no page change.

    You might want to try actually answering the question WHY you need the loop.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  7. #7
    When I run the macro, error message appears regardless of cursor being active or not. Do you have any idea how to fix it?time management game

  8. #8
    Quote Originally Posted by John Wilson View Post
    Why would it. There is no page change.

    You might want to try actually answering the question WHY you need the loop.
    I want to show a countdown counter based on a specific algorithm with a specific purpose.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •