alexandruc
10-22-2009, 03:29 AM
Hello,
Summary: I need a macro that will force users to enable macros in order to use excel. Also I need a macro that will save and close excel automatically if the user is idle for more then "x" minutes/seconds but without messing up the manual save (or not save) and close.
I got the force users enable macros code from here:
vbaexpress.com/kb/getarticle.php?kb_id=379 (made by Ken Puls)
The problem appears when I try to make this code work with another code for saving closing the worbook automaticaly if the user is idle more then "x" minutes/seconds.
I figure the problem comes from the customsave rutine, but I have no ideea on how trick it when the save is done automaticaly without affecting the manual save and close or just close.
The code I tryed to integrate with Ken's code is the following:
Private Changed As Boolean
Option Explicit
Private Sub Workbook_Open()
Changed = False
Application.OnTime Now + TimeValue("00:00:15"), procedure:="ThisWorkbook.Auto_Close"
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, _
ByVal Source As Range)
Changed = True
End Sub
Private Sub Auto_Close()
If Changed = False Then
ThisWorkbook.Close
End If
Changed = False
Call Application.OnTime(Now + TimeValue("00:00:15"), "ThisWorkbook.Auto_Close")
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
End Sub
The code above was written by Simon Lloyd.
This problem was/is disscussed here:
http://www.thecodecage.com/forumz/members-excel-vba-programming/145619-conflict-between-auto-save-close-macro-show-hide-sheets-macro.html where RoyUK and Simon Lloyd helped me a lot (and I am very gratefull), but I haven't seen a working solution so far.
I also turned to this forum because the person who wrote the enable macros code that works best (from my point of view) is a member here, and he knows his code best, thus hopeing he could help integrate the 2 codes.
Attached is a failed attempt at integrating the the 2 codes.
Summary: I need a macro that will force users to enable macros in order to use excel. Also I need a macro that will save and close excel automatically if the user is idle for more then "x" minutes/seconds but without messing up the manual save (or not save) and close.
I got the force users enable macros code from here:
vbaexpress.com/kb/getarticle.php?kb_id=379 (made by Ken Puls)
The problem appears when I try to make this code work with another code for saving closing the worbook automaticaly if the user is idle more then "x" minutes/seconds.
I figure the problem comes from the customsave rutine, but I have no ideea on how trick it when the save is done automaticaly without affecting the manual save and close or just close.
The code I tryed to integrate with Ken's code is the following:
Private Changed As Boolean
Option Explicit
Private Sub Workbook_Open()
Changed = False
Application.OnTime Now + TimeValue("00:00:15"), procedure:="ThisWorkbook.Auto_Close"
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, _
ByVal Source As Range)
Changed = True
End Sub
Private Sub Auto_Close()
If Changed = False Then
ThisWorkbook.Close
End If
Changed = False
Call Application.OnTime(Now + TimeValue("00:00:15"), "ThisWorkbook.Auto_Close")
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
End Sub
The code above was written by Simon Lloyd.
This problem was/is disscussed here:
http://www.thecodecage.com/forumz/members-excel-vba-programming/145619-conflict-between-auto-save-close-macro-show-hide-sheets-macro.html where RoyUK and Simon Lloyd helped me a lot (and I am very gratefull), but I haven't seen a working solution so far.
I also turned to this forum because the person who wrote the enable macros code that works best (from my point of view) is a member here, and he knows his code best, thus hopeing he could help integrate the 2 codes.
Attached is a failed attempt at integrating the the 2 codes.