Display popup for a time period in Excel

前端 未结 5 1278
萌比男神i
萌比男神i 2021-01-23 17:41

I am trying to generate a popup that closes after a given WaitTime in seconds.

I consulted this link and this link.

I tried to apply the method from

5条回答
  •  孤街浪徒
    2021-01-23 18:43

    Another approach (if your would not work at all).

    Create a new userform named frm_Popup and add a label there named lbl_Message. Add the following void to userform code:

    Public Sub StartProcess(iTime As Integer)
        Me.lbl_Message.Caption = "The message box will close in " & iTime & " second(s)."
    End Sub
    

    then in your module:

    Sub ShowMessage()
        Dim iTimeToWait As Integer
            iTimeToWait = 2
    
        With frm_Popup
            .Show False
            Call .StartProcess(iTimeToWait)
        End With
    
        Application.OnTime Now + TimeValue("00:00:" & iTimeToWait), "HidePopup"
    End Sub
    
    Private Sub HidePopup()
        Unload frm_Popup
    End Sub
    

提交回复
热议问题