Hi XL-experts.
I am new here and I hope you can give me a suitable solution.
I am using the folowing code to show a timed message every 10 minutes. If the user wants to continue working, he must click the OK button.
Else the workbook will close, so others can work with it.
code:
Sub TimedMessage()
Const Title As String = "Self closing message box"
Const Delay As Byte = 5 ' Time in seconds
Const wButtons As Integer = 17 ' Buttons + icon
Dim wsh As Object, msg As String
Set wsh = CreateObject("WScript.Shell")
msg = Space(15) & "Hello," & vbLf & vbLf & "Press ok if you need more time "
wsh.Popup msg, Delay, Title, wButtons
If wsh.Popup(msg, Delay, Title, wButtons) = vbOK Then
Application.OnTime Now + TimeValue("00:10:00"), "TimedMessage"
Else
'SAVE AND CLOSE
Application.DisplayAlerts = False
ThisWorkbook.Save
ThisWorkbook.Close False
End If
Set wsh = Nothing
'
End Sub
The code is called after 10 minutes from Sub Workbook_Open().
Nice, all works fine, really perfect.
As long as the user is working with one Excel workbook.
But it is not rare that the user uses 2, 3 4 or even 5 workbooks at the same time, including the same code.
And then it is not working anymore.
The messages keep waiting for each other to pop up and continue.
I have tried so many things to solve it.
It just looks like it is only possible to use 1 pop up function in general and they are "communicating" with each other.
Doe someone knows a solution for this?
mario
Bookmarks