Automatically Create Message Box with Timer

Описание к видео Automatically Create Message Box with Timer

How to create a message box automatically that closes itself after a specific time using VBA.
Here's the complete VBA code:
Private Sub Workbook_Open()
startTimer
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
startTimer
End Sub

Option Explicit

Const PopupDurationSecs As Integer = 5

Sub startTimer()
Application.OnTime Now + TimeValue("00:00:05"), "myShellMessageBox"
End Sub
Sub myShellMessageBox()

Dim Result As Integer

Result = CreateObject("WScript.Shell").PopUp( _
"Keep this workbook open?", PopupDurationSecs, _
"Keep Workbook Open", 4 + 32)
'MsgBox Result
If Result = 6 Then
Exit Sub
ElseIf Result = 7 Then
'ThisWorkbook.Save
Application.Quit
End If
End Sub

For more on this method see the MSDN documentation at http://msdn.microsoft.com/en-us/libra...

Комментарии

Информация по комментариям в разработке