Put all your code in a general module. ( in the VBE, insert=Module)
Then call the appropriate code from the workbook level selectionchange event
in the Thisworkbook module.
the public variable will be visible to the thisworkbook module as well. (you
can assign them a value and read them from there if you need to).
--
Regards,
Tom Ogilvy
evillen wrote in message
...
I have been looking at this again, and I believe that the problem has
something to do with my Public Const declarations - the previous code
was altered to make the constants local to the StartTimer process.
" get a warning that Constants are not allowed as Public members of
object modules". Please see code example below:
--------------------------------------------------------------------------
-
Public RunWhen As Double
Public Const cRunIntervalSeconds = 120 ' two minutes
Public Const cRunWhat = "The_Sub"
Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat, _
schedule:=True
End Sub
Sub The_Sub()
Msg = "Please close this workbook"
MsgBox (Msg)
StartTimer
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, _
procedu=cRunWhat, schedule:=False
End Sub
------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/