ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Vba - automaticaly closing userform (https://www.excelbanter.com/excel-programming/307679-vba-automaticaly-closing-userform.html)

ajliaks[_30_]

Vba - automaticaly closing userform
 
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


---
Message posted from http://www.ExcelForum.com/


Harald Staff

Vba - automaticaly closing userform
 
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

"ajliaks " skrev i melding
...
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


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 12:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com