Hello all,
I am having an issue where this workbook will reopen after closing. I've googled many different solutions, and still can't get it to stop. The idea behind this is that if the workbook is inactive, then a userform will pop up informing them that they have 90 seconds to confirm they are still in the workbook or it will close the workbook. The User form will call "closeit" sub to close the workbook. Clicking the button on the userform will type a value into the intro sheet which will update the formulas in B1 to give a new time before the sheet can be considered "inactive". (Also for testing purposes, macro_timer will run every 2 minutes, though it will be every 30 in the finished product.) I should note that it does work perfectly (except that it reopens, lol)
Any help would be greatly appreciated!!
I am having an issue where this workbook will reopen after closing. I've googled many different solutions, and still can't get it to stop. The idea behind this is that if the workbook is inactive, then a userform will pop up informing them that they have 90 seconds to confirm they are still in the workbook or it will close the workbook. The User form will call "closeit" sub to close the workbook. Clicking the button on the userform will type a value into the intro sheet which will update the formulas in B1 to give a new time before the sheet can be considered "inactive". (Also for testing purposes, macro_timer will run every 2 minutes, though it will be every 30 in the finished product.) I should note that it does work perfectly (except that it reopens, lol)
Any help would be greatly appreciated!!
VBA Code:
Public interval As Double
Sub macro_timer()
interval = Now + TimeValue("00:02:00")
Application.OnTime interval, "my_macro"
End Sub
Sub my_macro()
Dim Today
'Dim oldsheet As String
Today = Now
'---------------------INSERT FILE NAME HERE------------------------------------------
With Workbooks("PPP Play test")
'oldsheet = ActiveSheet.Name
Workbooks("PPP Play test").Activate
Sheets("INTRO").Visible = True
Sheets("INTRO").Select
If Today > Range("B1").Value Then
WakeUpCall.Show ([False])
Else
End If
'Sheets(oldsheet).Select
Sheets(1).Select
Sheets("INTRO").Visible = xlSheetVeryHidden
Call macro_timer
End With
End Sub
Sub stop_macro()
Application.OnTime Earliesttime:=interval, Procedure:="my_macro", Schedule:=False
End Sub
Sub closeit()
'Dim oldsheet As String
'---------------------INSERT FILE NAME HERE------------------------------------------
With Workbooks("PPP Play test")
'oldsheet = ActiveSheet.Name
Workbooks("PPP Play test").Activate
If Sheets("INTRO").Range("A2").Value = "1" Then
Application.ScreenUpdating = False
Sheets("INTRO").Visible = True
Sheets("INTRO").Select
Range("A2").Select
ActiveCell.FormulaR1C1 = ""
Range("A4").Select
'Sheets(oldsheet).Select
Sheets("INTRO").Visible = xlSheetVeryHidden
Application.ScreenUpdating = True
Unload WakeUpCall
Else
ActiveWorkbook.Save
ActiveWorkbook.Close
End If
End With
End Sub