Hello all,
I have a userform that will automatically close after a set amount of time. My challenge is, that using application.Wait doesn't allow the user to click on a command button to intervene. In this case the command button just closes the workbook immediately instead of waiting. Is there an alternative piece of code that would allow the user to override the wait (similar to ctrl+brk) or this there an alternative to using the wait function to accomplish a timer/countdown?
Thanks!
I have a userform that will automatically close after a set amount of time. My challenge is, that using application.Wait doesn't allow the user to click on a command button to intervene. In this case the command button just closes the workbook immediately instead of waiting. Is there an alternative piece of code that would allow the user to override the wait (similar to ctrl+brk) or this there an alternative to using the wait function to accomplish a timer/countdown?
Thanks!
VBA Code:
Private Sub UserForm_Activate()
With NEBULA
.StartUpPosition = 0
.Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
.Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
End With
Application.Wait (Now + TimeValue("00:00:01"))
NEBULA.Load_Label.Caption = "Loading Workbook data and settings.."
NEBULA.Repaint
Application.Wait (Now + TimeValue("00:00:04"))
NEBULA.Load_Label.Caption = "Hiding from Thanos..."
NEBULA.Repaint
Application.Wait (Now + TimeValue("00:00:02"))
NEBULA.Load_Label.Caption = "Preparing the workbook.."
NEBULA.Repaint
Application.Wait (Now + TimeValue("00:00:03"))
NEBULA.Load_Label.Caption = "Finishing up and opening..."
NEBULA.Repaint
Application.Wait (Now + TimeValue("00:00:02"))
NEBULA.Load_Label.Caption = ""
NEBULA.Repaint
If Workbooks.Count > 1 Then
NEBULA.Load_Label.Caption = "I work better alone." & vbNewLine & "Please close any other workbooks and tell Gamora to GET LOST!!!"
NEBULA.Repaint
Application.Wait (Now + TimeValue("00:00:02"))
NEBULA.multi_Label.Caption = "Closing workbook in 10 seconds..."
NEBULA.Repaint
Application.Wait (Now + TimeValue("00:00:01"))
NEBULA.multi_Label.Caption = "Closing workbook in 9 seconds..."
NEBULA.Repaint
Application.Wait (Now + TimeValue("00:00:01"))
NEBULA.multi_Label.Caption = "Closing workbook in 8 seconds..."
NEBULA.Repaint
Application.Wait (Now + TimeValue("00:00:01"))
NEBULA.multi_Label.Caption = "Closing workbook in 7 seconds..."
NEBULA.Repaint
Application.Wait (Now + TimeValue("00:00:01"))
NEBULA.multi_Label.Caption = "Closing workbook in 6 seconds..."
NEBULA.Repaint
Application.Wait (Now + TimeValue("00:00:01"))
NEBULA.multi_Label.Caption = "Closing workbook in 5 seconds..."
NEBULA.Repaint
Application.Wait (Now + TimeValue("00:00:01"))
NEBULA.multi_Label.Caption = "Closing workbook in 4 seconds..."
NEBULA.Repaint
Application.Wait (Now + TimeValue("00:00:01"))
NEBULA.multi_Label.Caption = "Closing workbook in 3 seconds..."
NEBULA.Repaint
Application.Wait (Now + TimeValue("00:00:01"))
NEBULA.multi_Label.Caption = "Closing workbook in 2 seconds..."
NEBULA.Repaint
Application.Wait (Now + TimeValue("00:00:01"))
NEBULA.multi_Label.Caption = "Closing workbook in 1 second..."
NEBULA.Repaint
Application.Wait (Now + TimeValue("00:00:01"))
NEBULA.Repaint
ActiveWorkbook.Saved = True
Application.Visible = True
Workbooks("NEBULA").Close
'Multi.Show
Exit Sub
End If
NEBULA.Main_Label.Caption = "Hi There!" & vbNewLine & "What would you like to do?"
NEBULA.Repaint
NEBULA.Create_GP.Visible = True
NEBULA.Close_Program.Visible = True
NEBULA.Infinity.Visible = True
End Sub