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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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