Application.ontime is running even after Excel workbook is closed
Posted on 2012-04-04
I have an excel 2007 workbook. I need to automatically close it after 5 minutes of opening it. I had written a code as under and this works
Private Sub Workbook_Open()
Application.OnTime Now() + TimeValue("00:05:00"), "Autoclose"
However, in case I close this Excel workbook after 2 minutes of opening it, the Excel application is still opening the closed workbook and then again closing it.
This should not happen. The excel application should close only if the Excel application is manually opened by me. Please suggest a method / VBA code.