OnTime-problem

B

Bo Hansson

On a user form I have a stack of images that I would like to browse by
changing the ZOrder every 5th second.
I've tried to use the OnTime-function, but it seems like the function does
not execute as long as the form is visible.
What's wrong?

/BosseH
 
H

Helmut Weber

Hi Bo,

you have to show your userform in mode vbmodeless,
like this, which changes the caption "x" of a commandbutton
every two seconds:

Sub test()
UserForm2.Show vbModeless
Call Mytime
End Sub
'---
Sub Mytime()
With UserForm2.CommandButton1
If .Caption = "x" Then
.Caption = "y"
Else
.Caption = "x"
End If
End With
Application.OnTime _
When:=Now + TimeValue("00:00:02"), _
Name:="Mytest"
End Sub
'---
Sub Mytest()
Mytime
End Sub

HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
H

Helmut Weber

....

and of course you have to make sure
to end the ontime macro in some way...

Helmut Weber
 

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