J
jtfalk
i have a file that I have put in an auto-open on that asks if you are there
after 10 minutes, if you do not click yes it saves and closes the workbook
but not excel (incase there is another workbook open). So the problem is if
there are 2 or 3 workbooks open if I close the workbook myslf after 10
minutes it actually reopens the disable/enable macro box and then will show
my yes/no are you there box. On close what can I put in to shut off all
macro's in the workbook?
On close I need to STOP the Application.OnTime Now() +
TimeValue("00:00:50"), "CloseMe"
Sub Autpen()
LogInformation ThisWorkbook.Name & " opened by " & Application.UserName &
" " & Format(Date, "yyyy-mm-dd") & " " & Format(Time, "hh:mm")
Application.OnTime Now() + TimeValue("00:00:50"), "CloseMe"
End Sub
'requires reference to "Windows Script Host Object Model"
Public Sub CloseMe()
Dim SH As IWshRuntimeLibrary.WshShell
Dim Res As Long
Set SH = New IWshRuntimeLibrary.WshShell
Res = SH.Popup(Text:="Are you still there? Please click Yes or this file
will close in 2 minutes", secondstowait:=2, _
Title:="Active", Type:=vbYesNo)
If Res = vbYes Then
Application.OnTime Now() + TimeValue("00:00:50"), "CloseMe"
Else
ThisWorkbook.Save
ThisWorkbook.Close
End If
End Sub
after 10 minutes, if you do not click yes it saves and closes the workbook
but not excel (incase there is another workbook open). So the problem is if
there are 2 or 3 workbooks open if I close the workbook myslf after 10
minutes it actually reopens the disable/enable macro box and then will show
my yes/no are you there box. On close what can I put in to shut off all
macro's in the workbook?
On close I need to STOP the Application.OnTime Now() +
TimeValue("00:00:50"), "CloseMe"
Sub Autpen()
LogInformation ThisWorkbook.Name & " opened by " & Application.UserName &
" " & Format(Date, "yyyy-mm-dd") & " " & Format(Time, "hh:mm")
Application.OnTime Now() + TimeValue("00:00:50"), "CloseMe"
End Sub
'requires reference to "Windows Script Host Object Model"
Public Sub CloseMe()
Dim SH As IWshRuntimeLibrary.WshShell
Dim Res As Long
Set SH = New IWshRuntimeLibrary.WshShell
Res = SH.Popup(Text:="Are you still there? Please click Yes or this file
will close in 2 minutes", secondstowait:=2, _
Title:="Active", Type:=vbYesNo)
If Res = vbYes Then
Application.OnTime Now() + TimeValue("00:00:50"), "CloseMe"
Else
ThisWorkbook.Save
ThisWorkbook.Close
End If
End Sub