C
Cajeto 63
Hello Everybody,
I have copied a code for a timer in a post and applied it to my workbook to
automatically show a userform after a short period of time.
My big problem is that when I close the workbook without quitting Excel the
timer continue running and re-open my workbook after the preset period to
show the userform again.
Is there a way to have the timer stopped when closing the workbook?
My code bellow:
In Module:
Option Explicit
Public nSaveWB As Date
Public Sub SetSaveWBTimer()
nSaveWB = Now + TimeSerial(0, 0, 5) ' 5 minutes
Application.OnTime nSaveWB, "SaveWB"
End Sub
Public Sub SaveWB()
Alerte.Show
End Sub
In ThisWorkbook:
Private Sub workbook_open()
Alerte.Show
End Sub
In Userform: (called Alerte)
Private Sub CommandButton1_Click()
Alerte.Hide
Call SetSaveWBTimer
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Call SetSaveWBTimer
End If
End Sub
Thanks for your help.
I have copied a code for a timer in a post and applied it to my workbook to
automatically show a userform after a short period of time.
My big problem is that when I close the workbook without quitting Excel the
timer continue running and re-open my workbook after the preset period to
show the userform again.
Is there a way to have the timer stopped when closing the workbook?
My code bellow:
In Module:
Option Explicit
Public nSaveWB As Date
Public Sub SetSaveWBTimer()
nSaveWB = Now + TimeSerial(0, 0, 5) ' 5 minutes
Application.OnTime nSaveWB, "SaveWB"
End Sub
Public Sub SaveWB()
Alerte.Show
End Sub
In ThisWorkbook:
Private Sub workbook_open()
Alerte.Show
End Sub
In Userform: (called Alerte)
Private Sub CommandButton1_Click()
Alerte.Hide
Call SetSaveWBTimer
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Call SetSaveWBTimer
End If
End Sub
Thanks for your help.