Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 4 of 4

Thread: PowerPoint Macro; Continually Run

  1. #1
    Join Date
    4th November 2005
    Location
    Hertfordshire, UK
    Posts
    224

    PowerPoint Macro; Continually Run

    Hi All,

    I'm running a Macro in PowerPoint (A countdown), that I want to update every second while the presentation is being run.

    Where do I have to put the code to initiate the macro and what syntax do I have to use to get the loop to happen every second (Application.Wait doesn't seem to be avaiable in PPt).

    Here's the code so far...

    VB:
     
    Private Sub UPdateCLock() 
         
        Dim DaysY As Double, DaysZ As Double 
        Dim HoursX As Double, HoursY As Double, HoursZ As Double 
        Dim MinsX As Double, MinsY As Double, MinsZ As Double 
        Dim SecsX As Double, SecsY As Double, SecsZ As Double 
         
        Do 
             
            DaysY = (34969875 / 900) - Now 
             
            DaysZ = Round(DaysY - 0.5, 0) 
             
            HoursX = DaysY - DaysZ 
            HoursY = HoursX * 24 
            HoursZ = Round(HoursY - 0.5, 0) 
             
            MinsX = HoursY - HoursZ 
            MinsY = MinsX * 60 
            MinsZ = Round(MinsY - 0.5, 0) 
             
            SecsX = MinsY - MinsZ 
            SecsY = SecsX * 60 
            SecsZ = Round(SecsY, 0) 
             
            Shapes("TextBox1").OLEFormat.Object.Text = DaysZ & " Dys " & HoursZ & " Hrs " _ 
            & MinsZ & " Mins " & SecsZ & " Secs until the Spring Conference" 
             
            DoEvents 
             
        Loop 
    End Sub 
    
    
    Any help appreciated, this my first Macro outside of Excel...

    Thanks,
    Ian

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    8th March 2006
    Posts
    3

    Re: PowerPoint Macro; Continually Run

    Hi Ian,

    I am taking a look at your problem and will get back to you when I have a solution. I assume you want the timer to run during the slide show.

    I don't spend much time in this forum so please drop me an email via my website:
    www.bettersolutions.com

    I will then be able to send you the solution.

    regards
    Russell

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    7th March 2003
    Location
    Essex, England
    Posts
    11,310

    Re: PowerPoint Macro; Continually Run

    Hi,

    You could try this. Place the textbox on the slidemaster.
    Add a class module called Class1
    VB:
    Public WithEvents MyApp As Application 
     
    Private Sub MyApp_SlideShowBegin(ByVal Wn As SlideShowWindow) 
         
        g_blnRunning = True 
        UPdateCLock 
         
    End Sub 
    Private Sub MyApp_SlideShowEnd(ByVal Pres As Presentation) 
         
        g_blnRunning = False 
         
    End Sub 
    Private Sub MyApp_SlideShowNextSlide(ByVal Wn As SlideShowWindow) 
        UPdateCLock 
    End Sub 
    
    
    Standard code module
    VB:
    Option Explicit 
     
    Public g_blnRunning As Boolean 
    Public g_clsApp As Class1 
     
    Sub Start() 
         
        If g_clsApp Is Nothing Then 
            Set g_clsApp = New Class1 
            Set g_clsApp.MyApp = Application 
        End If 
        g_blnRunning = True 
        ActivePresentation.SlideShowSettings.Run 
        UPdateCLock 
    End Sub 
     
    Public Sub UPdateCLock() 
         
        Dim DaysY As Double, DaysZ As Double 
        Dim HoursX As Double, HoursY As Double, HoursZ As Double 
        Dim MinsX As Double, MinsY As Double, MinsZ As Double 
        Dim SecsX As Double, SecsY As Double, SecsZ As Double 
         
        Do While g_blnRunning 
            DaysY = (34969875 / 900) - Now 
             
            DaysZ = Round(DaysY - 0.5, 0) 
             
            HoursX = DaysY - DaysZ 
            HoursY = HoursX * 24 
            HoursZ = Round(HoursY - 0.5, 0) 
             
            MinsX = HoursY - HoursZ 
            MinsY = MinsX * 60 
            MinsZ = Round(MinsY - 0.5, 0) 
             
            SecsX = MinsY - MinsZ 
            SecsY = SecsX * 60 
            SecsZ = Round(SecsY, 0) 
             
            ActivePresentation.SlideMaster.Shapes("TextBox1").OLEFormat.Object.Text = DaysZ & " Days " & HoursZ & " Hrs " _ 
            & MinsZ & " Mins " & SecsZ & " Secs until the Spring Conference" 
            DoEvents 
        Loop 
         
    End Sub 
    
    
    Start the presentation by running the macro Startup.
    Attached Files. REMINDER! OzGrid accepts no responsibility for ANY adverse effects as a result from downloading attached files. ALWAYS run an up-to-date virus scan and disable macros.

    Cheers
    Andy


  4. #4
    Join Date
    8th March 2006
    Posts
    3

    Re: PowerPoint Macro; Continually Run

    Nice solution Andy.

    I will have to be quicker next time

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. Continually Run Macro Code At Time Intervals
    By rockettpunk in forum EXCEL HELP
    Replies: 2
    Last Post: May 7th, 2008, 01:26
  2. Continually Rotate Image
    By Jekyll in forum Excel and/or Word Help
    Replies: 3
    Last Post: May 4th, 2008, 18:37

Bookmarks

Posting Permissions

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