Announcement

Collapse
No announcement yet.

change label.caption automatically on powerpoint userform

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • change label.caption automatically on powerpoint userform



    I want to be able display label1.caption and then have it change after a certain amount of time

  • #2
    Re: change label.caption automatically on powerpoint userform

    PowerPoint does not have an .ONTIME() event like Excel, so this will have to be done using the Windows API.

    Add a userform to a PowerPoint project. Add one Label control and one commandbutton. Leave all properties as the default.

    Add the following to the userform code module
    Code:
    Option Explicit
    
    Private Sub CommandButton1_Click()
    
        If CommandButton1.Caption <> "Close" Then
            Label1.Caption = "Waiting 5 secs..."
            CommandButton1.Enabled = False
            DoEvents
            StartTimer
        Else
            Unload Me
        End If
    
    End Sub
    Add a module and copy the following
    Code:
    Option Explicit
    Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal _
        lpTimerFunc As Long) As Long
    
    Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
    
    Dim lTimerID As Long
    Dim bTimer As Boolean
    
    Sub StartTimer()
    
        If bTimer Then
        
            lTimerID = KillTimer(0, lTimerID)
            
            If lTimerID = 0 Then
                MsgBox "Error - Unable to stop timer.", vbExclamation, "Error"
                UserForm1.CommandButton1.Enabled = True
                Exit Sub
            End If
            
            bTimer = False
            
        Else
            
            '// Timer intervals in the API are milliseconds. 5000 = 5 seconds
            lTimerID = SetTimer(0, 0, 5000, AddressOf TItleIT)
            
            If lTimerID = 0 Then
                MsgBox "Error - Unable to start timer...", vbExclamation, "Error"
                UserForm1.CommandButton1.Enabled = True
                Exit Sub
            End If
            bTimer = True
            
        End If
        
        UserForm1.CommandButton1.Caption = "Close"
        
    End Sub
    
    Public Sub TItleIT()
    
        With UserForm1
            .Label1.Caption = Now()
            .CommandButton1.Enabled = True
        End With
        
    End Sub

    Comment


    • #3


      Re: change label.caption automatically on powerpoint userform

      Thanks worked Perfect, much appreciated

      Comment

      Working...
      X