Timer abort

rjplante

Well-known Member
Joined
Oct 31, 2008
Messages
569
Office Version
  1. 365
Platform
  1. Windows
I have a spreadsheet that I have set up an autosave timer using VBA (see code below). When I close the workbook the timer keeps running, and will open the workbook to resave the document if I have other spreadsheets open. How do I kill the timer when the workbook closes? I know I will add it to the ThisWorkbook code window, and use the before close option, but what is the line of code to abort the timer?

Tanks for the help.

VBA Code:
Sub SaveThis()

Application.DisplayAlerts = False

ThisWorkbook.Save

Application.DisplayAlerts = True

Application.OnTime Now + TimeValue("00:05:00"), "SaveThis"

End Sub
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
your OnTime needs to be cancelled with your workbook close, as it will as you have discovered keep running continually, many references to code on here when you search for them
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top