L
louieuow
I am trying to use the OnTimer event to run a macro every 60 seconds while a
workbook is open.
I found lots of examples on the net and the example below on this site.
Regardless of which example I use I always get this error message when the
OnTimer event is triggered
The macro 'macro name' cannot be found.
I have tried this on several Computers - Staff machines, student lab
machines, admin assistant machines, and they all produce the same error
message each time, and the Macro Security level is set to the Not recomended
Low setting, so I know its not a fault with my PC.
We use Office 2003 with SP 3
I am writing a templating system/procedure for excel to allow Lecturers to
produce student excel template lab exercises that will reduce the temptation
for students to cheat ( cut/paste other people work, submit another's
workbook etc). The ontimer event is ment to show the lab demostrators in real
time how long the student has been working on the exercise, was they walk
around the lab.
//------------------------------------------
Private mNextTime As Double
Private mCounter As Long ' for test routine
Sub OnTimer()
mNextTime = Now + (TimeSerial(0, 0, 1))
Application.OnTime mNextTime, "myMacro"
End Sub
Sub StopTimer()
' call StopTimer in the workbook's close event or antime to stop the OnTime
If mNextTime Then Application.OnTime mNextTime, "myMacro", Schedule:=False
mNextTime = 0
End Sub
Sub myMacro()
''' do stuff
mCounter = mCounter + 1
Cells(mCounter, 1) = Format(mNextTime, "hh:mm:ss")
''' do stuff done
OnTimer
End Sub
workbook is open.
I found lots of examples on the net and the example below on this site.
Regardless of which example I use I always get this error message when the
OnTimer event is triggered
The macro 'macro name' cannot be found.
I have tried this on several Computers - Staff machines, student lab
machines, admin assistant machines, and they all produce the same error
message each time, and the Macro Security level is set to the Not recomended
Low setting, so I know its not a fault with my PC.
We use Office 2003 with SP 3
I am writing a templating system/procedure for excel to allow Lecturers to
produce student excel template lab exercises that will reduce the temptation
for students to cheat ( cut/paste other people work, submit another's
workbook etc). The ontimer event is ment to show the lab demostrators in real
time how long the student has been working on the exercise, was they walk
around the lab.
//------------------------------------------
Private mNextTime As Double
Private mCounter As Long ' for test routine
Sub OnTimer()
mNextTime = Now + (TimeSerial(0, 0, 1))
Application.OnTime mNextTime, "myMacro"
End Sub
Sub StopTimer()
' call StopTimer in the workbook's close event or antime to stop the OnTime
If mNextTime Then Application.OnTime mNextTime, "myMacro", Schedule:=False
mNextTime = 0
End Sub
Sub myMacro()
''' do stuff
mCounter = mCounter + 1
Cells(mCounter, 1) = Format(mNextTime, "hh:mm:ss")
''' do stuff done
OnTimer
End Sub