display userform for 10 seconds

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
 
O

Orion Cochrane

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.
 
S

Sandy

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
 
S

Sandy

It is meant to simply display a message - "For further information refer to
bla bla" - for 10 seconds.
Sandy
 
O

Orion Cochrane

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.
 
P

papou

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top