locked
Running multiple macros at the same time on PowerPoint 2007....? RRS feed

  • Question

  • Hi,

    I have 2 macros in a presentation in Powerpoint 2007 - secBank and BeginCount.

    secBank takes a value from a text box in the current slide and passes this back as a variable to another slide - keeping score as someone goes along.  This is called from a button with the macro assigned.

    Secondly I have a timer macro - BeginCount.  This updates a text box on the current slide to the current time remaining.  After a set time it takes you back to the first slide so you cannot proceed any further.

    I want to be able to keep the BeginCount running throughout the slideshow constantly updating the text box to the current time remaining.  This works fine if it is just this macro running.  However when I use the secBank macro, the BeginCount stops running.

    The code is below - basically all I want is for the secBank macro to only pause then resume the BeginCount macro (at worst), or both to be able to run concurrently - opinions differ on this depending where you look so I need a definitive solution!

     

    Sub secBank()

    Dim Add As Long
    Dim Tot As Long
    Dim Overall As Long

    Add = ActivePresentation.SlideShowWindow.View.Slide.Shapes("Amount").TextFrame.TextRange.Text
    Tot = ActivePresentation.Slides(4).Shapes("Total").TextFrame.TextRange.Text

    Overall = Add + Tot

    ActivePresentation.Slides(4).Shapes("Total").TextFrame.TextRange.Text = Add + Tot

    ActivePresentation.SlideShowWindow.View.GotoSlide (4)
    ActivePresentation.SlideShowWindow.View.Slide.Shapes("Time").TextFrame.TextRange.Text = minutes & ":" & seconds
    End Sub

    **************************************************************

    Sub BeginCount()
    Dim serviceStart As Long
    Dim serviceStartTime As Long
    Dim minutes As Long
    Dim seconds As Long

    serviceStart = InputBox("How long is the round (in seconds)?")
    If serviceStart > 1000 Or serviceStart < 0 Then
    MsgBox "Sorry, you must pick a number between 0 and 1000"
    Else

    serviceStartTime = (serviceStart) + Timer
    While Timer < serviceStartTime
    DoEvents
    minutes = Int((serviceStartTime - Timer) / 60)
    seconds = (serviceStartTime - Timer) Mod 60
    ActivePresentation.SlideShowWindow.View.Slide.Shapes("Time").TextFrame.TextRange.Text = minutes & ":" & seconds
    If minutes = 0 And seconds = 0 Then
    ActivePresentation.SlideShowWindow.View.GotoSlide (4)
    End If
    Wend
    End If
    End Sub

    ***************************************

    To try this for yourself create a presentation with around 10 slides.  On slide 4 add a button and assign the secBank macro to it.  Create a text box on slides 4 onwards called "Time" with a value of 0 in each text box.  Also create a text box on each slide called "Amount" and in each slide assign it a different value - i.e. slide 4 has a value of 4, slide 5 has a value of 5 and so on.  Also create a shape on each slide and assign the Macro secBank to it on each slide

    On slide 4 create a text box called "Total" and set the value to 0.

    Run the presentation and run the macro BeginCount - input a time in seconds in the box that appears, the timer will start.  Progress through the slides and randmly click the shape with the macro secBank assigned to it and it stops the timer countdown.  If you don't run it and leave the timer to go to 0.00 it will take you back to slide 4.

    I need the timer to continue counting down whilst the secBank macro runs - any ideas?  I have though about a loop or doevents function but cannot get my head round getting them both to run without breaking each other....


    • Edited by mattcp Thursday, August 27, 2009 2:24 PM
    Thursday, August 27, 2009 2:22 PM