Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Powerpoint VBA macro Form help

  • 24-07-2011 2:11pm
    #1
    Registered Users, Registered Users 2 Posts: 7,893 ✭✭✭


    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,056 ✭✭✭✭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