short message after button click

  • Thread starter Thread starter RuudS
  • Start date Start date
R

RuudS

When a userform is visible and a button has been clicked;
how can VBA show a message for 2 seconds and then hide
this message automatically (without having to click [OK])?

I have tried:

Private Sub CommandButton3_Click()
'[...]
...Form_message.Show
...Call Slaap '(predefined, waits 2 seconds)
...Form_message.Hide
'[...]
End Sub

But this doesn't work. Other options?

Ruud
 
When you show the form use .show modeless that will open the form and
let the code continue or you could put a timer object on the current
form and have it start on the form load and then when it hits a certain
time have it close itself.

Keith
www.kjtfs.com
*When a userform is visible and a button has been clicked;
how can VBA show a message for 2 seconds and then hide
this message automatically (without having to click [OK])?

I have tried:

Private Sub CommandButton3_Click()
'[...]
...Form_message.Show
...Call Slaap '(predefined, waits 2 seconds)
...Form_message.Hide
'[...]
End Sub

But this doesn't work. Other options?

Ruud *
 
Ruud,

You need to use OnTime

The button code would look like

Private Sub CommandButton1_Click()
Form_Message.Show
End Sub

Add this code to your userform

Private Sub UserForm_Activate()
Application.OnTime Now + TimeValue("00:00:02"), "my_Procedure"
End Sub

and put this code in a normal code module

Sub my_Procedure()
Form_Message.Hide
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Ruud,

Set a reference to the Windows Script Host object model, and use
code like the following:

Dim WSH As WshShell
Set WSH = New WshShell
WSH.Popup Text:="Hello", SecondsToWait:=2


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Thanckxs!


-----Original Message-----
Ruud,

You need to use OnTime

The button code would look like

Private Sub CommandButton1_Click()
Form_Message.Show
End Sub

Add this code to your userform

Private Sub UserForm_Activate()
Application.OnTime Now + TimeValue ("00:00:02"), "my_Procedure"
End Sub

and put this code in a normal code module

Sub my_Procedure()
Form_Message.Hide
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

When a userform is visible and a button has been clicked;
how can VBA show a message for 2 seconds and then hide
this message automatically (without having to click [OK])?

I have tried:

Private Sub CommandButton3_Click()
'[...]
..Form_message.Show
..Call Slaap '(predefined, waits 2 seconds)
..Form_message.Hide
'[...]
End Sub

But this doesn't work. Other options?

Ruud


.
 
Back
Top