Auto Initiate Excel Macro

Hi. I am trying to figure out how to write a macro for Excel that will check the time that the workbook has been idle (i.e. has not been changed) and under certain circumstances, close the workbook.

I am currently achieving this by using a 'DoEvents' command that will relinquish control of the workbook to the user while the Macro runs a timer in the background but this causes somebehavioral quirks that are not good.

Does anybody know how to get Excel to initiate a Macro to run after a time delay or on a set schedule?

[956 byte] By [Jon77] at [2008-2-26]
# 1
I'm looking to do the same, and I think I may have found my answer here:

http://www.cpearson.com/excel/ontime.htm

- Tumnus123

Tumnus123 at 2007-9-9 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...
# 2

Looks like the code on this page won't work within Excel XP. So far I have only copy and paste the code in and tried it but on compile it comes back with an error

"Constants, Fixed-length Strings, arrays, User defined types and declare statments not allowed as public members of object modules"

I am still trying to get a grasp on how to write my own excel macros and admittedly am not that great with scripting at all so if there is anyone out there that can tell me where I am going wrong it would be appreciated.

Adam Scott

AdamScott at 2007-9-9 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...