Kemidan2014
Board Regular
- Joined
- Apr 4, 2022
- Messages
- 229
- Office Version
- 365
- Platform
- Windows
Good morning. I have a spreadsheet that up to 12 people in my department will be using through out the day and I currently have a macro in it to close the workbook out after 15 minutes of inactivity because shareing the workbooks prevents some functionality of it.
with some of users when it closes it closes until the next time they open the file
WIth others when the Autoclose runs it closes the file but then immediately reopens the file.
what would be the reason for this?
in a seperate module:
in This workbook:
with some of users when it closes it closes until the next time they open the file
WIth others when the Autoclose runs it closes the file but then immediately reopens the file.
what would be the reason for this?
in a seperate module:
VBA Code:
'Make Declarations
Option Explicit
Dim killtime As Variant
Dim Procedurename As String
Sub Starttimer()
'Run Stoptimer macro
Stoptimer
'Define killtime
killtime = Now + TimeValue("00:30:00")
'Define Procedurename
Procedurename = "Closethisworkbook"
'when time is up Run killtime and procedurename
Application.OnTime killtime, Procedurename
End Sub
Sub Stoptimer()
On Error Resume Next
'When timer is stopped it prevents killtime and procedurename from running
Application.OnTime killtime, Procedurename, , False
End Sub
Sub Closethisworkbook()
'Run Stoptimer Macro
Stoptimer
'Closes and saves workbook
Workbooks("Customer Complaint Tracker.xlsm").Close SaveChanges:=True
End Sub
in This workbook:
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Stoptimer
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Starttimer
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Starttimer
End Sub