Vba - automaticaly closing userform

A

ajliaks

Hi all,

i need to close the userform after 2 seconds.
Could anybody help me?
Thanks.

Iam trying something like this:

Private Sub UserForm_Initialize()
Dim cTime As Long
Dim WSH As Object

Set WSH = CreateObject("WScript.Shell")
cTime = 1

Wait cTime '?????

Unload Me
End Sub
 
H

Harald Staff

In a standard module:

Sub ShowForm()
UserForm1.Show
End Sub

Sub KillForm()
Unload UserForm1
End Sub

In the userform1 module:

Private Sub UserForm_Initialize()
Application.OnTime (Now + TimeSerial(0, 0, 2)), "KillForm"
End Sub

HTH. Best wishes Harald
 

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