save and close after idle vba

Cooky857

New Member
Joined
Jan 9, 2019
Messages
16
[FONT=&quot][FONT=&quot]Hi all [/FONT][/FONT]
[FONT=&quot][FONT=&quot][/FONT]
[/FONT]

[FONT=&quot][FONT=&quot]I’m looking for a vba-macro that will pop up a warning after 5 min inactivity and then save & close if still idle after 5 more min. [/FONT][/FONT]
[FONT=&quot][FONT=&quot][/FONT]
[/FONT]

[FONT=&quot][FONT=&quot]Ideally the clock would restart after the pop up is close.[/FONT][/FONT]
[FONT=&quot][FONT=&quot][/FONT]
[/FONT]

[FONT=&quot][FONT=&quot]Thanks in advance/ Office 2016 if it helps [/FONT][/FONT]
[FONT=&quot][FONT=&quot][/FONT]
[/FONT]

[FONT=&quot][FONT=&quot]Cooky857[/FONT][/FONT]
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
[FONT=&quot][FONT=&quot]Hi all [/FONT][/FONT]
[FONT=&quot][FONT=&quot][/FONT]
[/FONT]

[FONT=&quot][FONT=&quot]I’m looking for a vba-macro that will pop up a warning after 5 min inactivity and then save & close if still idle after 5 more min. [/FONT][/FONT]
[FONT=&quot][FONT=&quot][/FONT]
[/FONT]

[FONT=&quot][FONT=&quot]Ideally the clock would restart after the pop up is close.[/FONT][/FONT]
[FONT=&quot][FONT=&quot][/FONT]
[/FONT]

[FONT=&quot][FONT=&quot]Thanks in advance/ Office 2016 if it helps [/FONT][/FONT]
[FONT=&quot][FONT=&quot][/FONT]
[/FONT]

[FONT=&quot][FONT=&quot]Cooky857[/FONT][/FONT]
 
Upvote 0
Maybe this

Code:
Private Sub Workbook_Open()
StartTimer
End Sub

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
StartTimer
End Sub


Now right click 'ThisWorkbook' insert module and paste this code in. Save close and re-open the workbook and after 5 minutes of idle time it will save and close automatically.



Code:
Const idleTime = 300 'seconds
Dim Start
Sub StartTimer()
Start = Timer
Do While Timer < Start + idleTime
DoEvents
Loop
Application.DisplayAlerts = False
ActiveWorkbook.Close True
Application.DisplayAlerts = True
End Sub
 
Upvote 0
Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread.
Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).
I have merged both threads
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,313
Members
452,634
Latest member
cpostell

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