MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Helpp! possessed macro!

Posted by RoB on November 21, 2001 12:12 PM

Ok, i have a problem on my hands. I have an excel template with an auto shutdown after 15 minutes code in it. The code works fine. Recently, with the help of people on this board, i made a filesearch with an excel workbook. the file search is meant to find files, all of which use the above mentioned template.

Now, whats happening is, after a search is done, and a file is opened using the above template, then closed, about 15 minutes later, the file that was opened magically opens, saves, and closes again. This is begining to become a problem if for instance you have something open and are typing. Now, im not POSITIVE that its the shutdown part of the macro, but im 99% sure because of the timing. FYI, the search is being left open while files are opened and closed. Is the timer in the shutdown code maybe not stopping when the file is closed and continuing because the search is open?? PLEASE HELp! here is the shutdown code that is in each template (its NOT in the search code):

Dim DownTime As Date

Sub SetTime()
DownTime = Now + TimeValue("00:15:00")
Application.OnTime DownTime, "ShutDown"
End Sub
Sub ShutDown()

End Sub

Sub Disable()
On Error Resume Next
Application.OnTime EarliestTime:=DownTime, Procedure:="ShutDown", Schedule:=False
End Sub

Any help is appreciated!

Posted by RoB on November 21, 2001 12:15 PM

Oh, also:

I changed the code in the shutdown macro from :

I was getting even MORE problems with the and .close code because it would open, then close the active file, which wasnt supposed to happen! But even the changed files still open. -confused-!

Posted by RoB on November 21, 2001 12:20 PM

more information

Sorry, forgot to mention:

If i use a windows search to open a file, then close it, it will NOT open again and run the shutdown code, its only started happening since i started using the Excel FileSearch workbook.

Posted by Ivan F Moala on November 21, 2001 6:52 PM

Each time you open the workbook with the application.ontime routines you MUST terminate them properly befroe run the
Disable routine BEFORE shutting
terminate the ontime routine otherwise it will
continue to run.


Posted by RoB on November 22, 2001 1:40 AM

That would do it