When you open the workbook the OnTime event is set to run the procedure RunMeCloseIt at 6AM. If you close the workbook, but leave Excel open, the Ontime event is still set. When 6AM arrives, Excel opens the workbook in order to run the procedure.
What you need to do is cancel the OnTime event when you close the workbook, like this:
Code:Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.OnTime EarliestTime:=TimeValue("06:00:00"), Procedure:="RunMeCloseIt", Schedule:=False End Sub


LinkBack URL
About LinkBacks



Reply With Quote

Bookmarks