display userform for 10 seconds

  • Thread starter Thread starter Sandy
  • Start date Start date
S

Sandy

Hi
I am trying to have a UserForm display for 10 seconds and then have the rest
of my sub proceed.


have tried

********
frmPrime.Show
Application.Wait Now + TimeValue("00:00:10")
frmPrime.Hide
********

but this just stops the code permanently. Any ideas?
Sandy
 
Try this:
UserForm object:
Private Sub UserForm_Activate()
Application.OnTime Now + TimeValue("00:00:10"), "KillTheForm"
End Sub

Kill Module
Private Sub KillTheForm()
Unload UserForm1
End Sub

I use this for making welcome splashes in certain programs. The
UserForm_Activate occurs when the userform is triggered by an event. The
userform will display for 10 seconds (as per OP), and the KillTheForm
procedure kicks in, which unloads the userform.
 
Hi guys

Both work very well with the exception that the information on the userform
(labels) does not display - any ideas why this should happen?

Sandy
 
It is meant to simply display a message - "For further information refer to
bla bla" - for 10 seconds.
Sandy
 
Make a label in the form big enough to display this message. Or you could
have a message box at the beginning of your code with the message. Once the
user clicks OK, the procedure will run. This may actually save time in that
the message box will not display for 10 seconds. Here's a sample of the
message box:
Sub Macro()
MsgBox "Your message here"
'Your code here
End Sub

The MsgBox will default to an OK button only if you copy my line to your
macro. I think the MsgBox route would be better, but I could be wrong.
 
Sandy
If the label already has text on it, and you want to change this text for
some time, then use the Repaint method:
Label1.Caption = ""For further information refer to bla bla"
UserForm1.Repaint
And use this method each time you change the label's text.

HTH
Cordially
Pascal
 
Back
Top