Tom Huntford
New Member
- Joined
- Nov 17, 2015
- Messages
- 3
I have searched and searched, but not found an answer to this:
I have a workbook that is shared by users, and needs to be auto-closed after 10 minutes of inactivity. The VBA code to close the workbook if no changes have been made in 10 min works OK. However, I want to give a user who has been using the workbook for 10 minutes, is actually there, an opportunity to keep the file open. So I need to have an input box or message box appear for a certain length of time, say, 10 seconds. "This workbook is about to be closed due to inactivity. Click "Yes" if you want to keep this workbook open." If no one responds to the prompt, the box is closed and the auto-close routine performs. If "Yes" is entered, the workbook is kept open.
This is what I have, but I don't like the way it works, its fluky.
Public Const ShowDurationSecs As Integer = 1.75
Public Const NUM_MINUTES = 10
Dim Rslt As Integer
Rslt = CreateObject("WScript.Shell").Popup( _
"This workbook has been inactive for more than " & NUM_MINUTES & " minutes." & vbNewLine & vbNewLine & "Keep this workbook open?", ShowDurationSecs, _
"Shared Workbook has been inactive...", 4 + 32)
If Rslt = 6 Then
End
Else: End If
Suggestions gratefully accepted.
I have a workbook that is shared by users, and needs to be auto-closed after 10 minutes of inactivity. The VBA code to close the workbook if no changes have been made in 10 min works OK. However, I want to give a user who has been using the workbook for 10 minutes, is actually there, an opportunity to keep the file open. So I need to have an input box or message box appear for a certain length of time, say, 10 seconds. "This workbook is about to be closed due to inactivity. Click "Yes" if you want to keep this workbook open." If no one responds to the prompt, the box is closed and the auto-close routine performs. If "Yes" is entered, the workbook is kept open.
This is what I have, but I don't like the way it works, its fluky.
Public Const ShowDurationSecs As Integer = 1.75
Public Const NUM_MINUTES = 10
Dim Rslt As Integer
Rslt = CreateObject("WScript.Shell").Popup( _
"This workbook has been inactive for more than " & NUM_MINUTES & " minutes." & vbNewLine & vbNewLine & "Keep this workbook open?", ShowDurationSecs, _
"Shared Workbook has been inactive...", 4 + 32)
If Rslt = 6 Then
End
Else: End If
Suggestions gratefully accepted.

Last edited: