API Timer

S

Seth

I am using the API timer functions to emulate the VB
timer capability in an Excel project (see following code):


--------------------------------------------------------
Public Declare Function SetTimer Lib "user32" (ByVal hwnd
As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As
Long
Public Declare Function KillTimer Lib "user32" (ByVal
hwnd As Long, ByVal nIDEvent As Long) As Long

Public TimerID As Long
Public TimerSeconds As Single

Sub StartTimer()
TimerSeconds = 1 ' how often to "pop" the timer.
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&,
AddressOf TimerProc)
End Sub

Sub EndTimer()
On Error Resume Next
KillTimer 0&, TimerID
End Sub

Sub TimerProc(ByVal hwnd As Long, ByVal uMsg As Long, _
ByVal nIDEvent As Long, ByVal dwTimer As Long)
' My code here
End Sub
--------------------------------------------------------

OK, so everything works well until I call the EndTimer
function (I call this function when I terminate a
userform). I go back to the Excel interface but I can't
use the mouse to click on anything (cells, toolbars,
etc.).

Anybody know what is going on here?

Thanks,

Seth
 
B

Bob Phillips

Seth,

I don't get this problem. You do have XL2000 or later don't you?

--

HTH

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

Seth

Yes, I have XL XP.

The problem is that once i turn off the timer, I cannot
get back into Excel (i.e., I can't click on anything, I
just get the standard mouse pointer - I can't select
cells, click buttons or anything). It is like Excel is
frozen almost, but I can still edit in the VBE.

It is odd, and I wasn't sure if anyone else had
experienced this.

Seth
 

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