Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Powerpoint VBA macro Form help

  • 24-07-2011 02:11PM
    #1
    Registered Users, Registered Users 2, Paid Member Posts: 8,012 ✭✭✭
    Something about sandwiches


    Hi,
    I've a simple macro that loads on a particular slide. Given a start date, it'll tell display how many days/minutes/seconds have elapsed since that date. I want it to be a live timer, but this slide will be in the middle of the presentation so I want to be able to move on afterwards.

    The code I have at the moment works to a degree. It'll calculate the days/mins/secs and the timer will tick away, however, its not "threaded" so the macro just keeps running and I can't move on to the next slide. Basically I need help with threading (is that even what its called in VBA? I come from a C++/java background).

    Here's my code:
     Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
        'If SSW.View.CurrentShowPosition = 3 Then
        Do While SSW.View.CurrentShowPosition = 3    ' infinite loop
            Dim currentSlide As Integer
            currentSlide = SSW.View.CurrentShowPosition
    
            Dim startDate As Date
            Dim currentDate As Date
            Dim sngDiff As Single
            Dim lngDays As Long
            Dim lngHours As Long
            Dim lngMinutes As Long
            Dim lngSeconds As Long
    
            startDate = #7/22/2011 2:00:00 PM#
            currentDate = Now
    
            sngDiff = currentDate - startDate
            lngDays = CLng(sngDiff)
            sngDiff = sngDiff - lngDays
            lngHours = Hour(sngDiff)
            lngMinutes = Minute(sngDiff)
            lngSeconds = Second(sngDiff)
    
            With ActivePresentation.Slides(currentSlide)
                With .Shapes(2)
                .TextFrame.TextRange.Text = "It has been:" & lngDays & " Days " & lngHours & " hours " & lngMinutes & " minutes " & lngSeconds & " Seconds"
                End With
            End With
    
        DoEvents
        Loop
    End Sub
    

    Can anyone show me how to fix this? I'm only new to macros. Apparently I've to make a "form" or something and load that from the subroutine??

    Thanks.


Comments

  • Closed Accounts Posts: 18,053 ✭✭✭✭BostonB


    I don't really know Powerpoint VBA. So this is just a guess.

    Isn't the problem that this is running all within the same window. You'd need to put it in a another window and leave that open in the foreground. Maybe thats a kludge and theres some other Powerpoint on screen object that persists between slides I dunno.


Advertisement