Auto save after inactivity.

Mick Peters

Board Regular
Joined
May 18, 2015
Messages
93
Hi I am new to this but am finding my way around using several pieces of code found on the web so I may look more advanced than I am.
Most of the code I have found does an auto save then a close. what I need is to be able to auto save but without the close. possibaly a message box open while the save is going on.
I have work sheets that are locked all except coulmn A and the users scan into the cells in column A and the work sheet does the rest. If there are no scans within 5 min then I would like to save the workbook.
I currently have this but it dose not account for inactivity,
Sub AutoSave()
dTime = Time + TimeValue("00:05:00")
With Application
.OnTime dTime, "AutoSave"
.EnableEvents = False
.DisplayAlerts = False
ThisWorkbook.SaveAs "C:\Autosave.xlsm"
.EnableEvents = True
End With
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.OnTime dTime, "AutoSave", , False
End Sub

Private Sub Workbook_Open()
dTime = Time + TimeValue("00:05:00")
Application.OnTime dTime, "AutoSave"
End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,214,918
Messages
6,122,241
Members
449,075
Latest member
staticfluids

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