Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
This is a strange and difficult issue. I'm running Application.OnTime to
close a shared workbook after 1 hour of inactivity. This prevents a user from locking up the workbook. When testing this on my home computer, it works well. However on the system at work there is a problem. It seems if the user is another workbook, Excel can't find the "SaveAndClose " macro (I don't recall the exact error message - something like "unable to locate macro "SaveAndClose". I do the same thing at home and it works fine. Any ideas on what could be causing this? The macro is shown below and is in the "ThisWorkbook" code. The SaveAndClose macro is in a general module. Thanks. Private Sub Workbook_Open() On Error Resume Next Application.OnTime RunWhen, "SaveAndClose", , False On Error GoTo 0 RunWhen = Now + TimeSerial(0, NUM_MINUTES, 0) Application.OnTime RunWhen, "SaveAndClose", , True End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error Resume Next Application.OnTime RunWhen, "SaveAndClose", , False On Error GoTo 0 End Sub Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) On Error Resume Next Application.OnTime RunWhen, "SaveAndClose", , False On Error GoTo 0 RunWhen = Now + TimeSerial(0, NUM_MINUTES, 0) Application.OnTime RunWhen, "SaveAndClose", , True End Sub Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _ ByVal Target As Range) On Error Resume Next Application.OnTime RunWhen, "SaveAndClose", , False On Error GoTo 0 RunWhen = Now + TimeSerial(0, NUM_MINUTES, 0) Application.OnTime RunWhen, "SaveAndClose", , True End Sub |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Where are you defining RUNWHEN and NUM_MINUTES?
"dhstein" wrote: This is a strange and difficult issue. I'm running Application.OnTime to close a shared workbook after 1 hour of inactivity. This prevents a user from locking up the workbook. When testing this on my home computer, it works well. However on the system at work there is a problem. It seems if the user is another workbook, Excel can't find the "SaveAndClose " macro (I don't recall the exact error message - something like "unable to locate macro "SaveAndClose". I do the same thing at home and it works fine. Any ideas on what could be causing this? The macro is shown below and is in the "ThisWorkbook" code. The SaveAndClose macro is in a general module. Thanks. Private Sub Workbook_Open() On Error Resume Next Application.OnTime RunWhen, "SaveAndClose", , False On Error GoTo 0 RunWhen = Now + TimeSerial(0, NUM_MINUTES, 0) Application.OnTime RunWhen, "SaveAndClose", , True End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error Resume Next Application.OnTime RunWhen, "SaveAndClose", , False On Error GoTo 0 End Sub Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) On Error Resume Next Application.OnTime RunWhen, "SaveAndClose", , False On Error GoTo 0 RunWhen = Now + TimeSerial(0, NUM_MINUTES, 0) Application.OnTime RunWhen, "SaveAndClose", , True End Sub Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _ ByVal Target As Range) On Error Resume Next Application.OnTime RunWhen, "SaveAndClose", , False On Error GoTo 0 RunWhen = Now + TimeSerial(0, NUM_MINUTES, 0) Application.OnTime RunWhen, "SaveAndClose", , True End Sub |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Have you tried
Application.Run "'" & thisworkbook.name & "'!SaveAndClose" "dhstein" wrote: This is a strange and difficult issue. I'm running Application.OnTime to close a shared workbook after 1 hour of inactivity. This prevents a user from locking up the workbook. When testing this on my home computer, it works well. However on the system at work there is a problem. It seems if the user is another workbook, Excel can't find the "SaveAndClose " macro (I don't recall the exact error message - something like "unable to locate macro "SaveAndClose". I do the same thing at home and it works fine. Any ideas on what could be causing this? The macro is shown below and is in the "ThisWorkbook" code. The SaveAndClose macro is in a general module. Thanks. Private Sub Workbook_Open() On Error Resume Next Application.OnTime RunWhen, "SaveAndClose", , False On Error GoTo 0 RunWhen = Now + TimeSerial(0, NUM_MINUTES, 0) Application.OnTime RunWhen, "SaveAndClose", , True End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error Resume Next Application.OnTime RunWhen, "SaveAndClose", , False On Error GoTo 0 End Sub Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) On Error Resume Next Application.OnTime RunWhen, "SaveAndClose", , False On Error GoTo 0 RunWhen = Now + TimeSerial(0, NUM_MINUTES, 0) Application.OnTime RunWhen, "SaveAndClose", , True End Sub Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _ ByVal Target As Range) On Error Resume Next Application.OnTime RunWhen, "SaveAndClose", , False On Error GoTo 0 RunWhen = Now + TimeSerial(0, NUM_MINUTES, 0) Application.OnTime RunWhen, "SaveAndClose", , True End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I find a macro in Excel? | Excel Worksheet Functions | |||
Excel 2K3 Macro - Find and Update | Excel Worksheet Functions | |||
How do I use find in a macro in Excel | Excel Worksheet Functions | |||
How do I find a Macro in Excel when I don't know its name? | Excel Discussion (Misc queries) | |||
macro to Find Replace in Excel | Excel Discussion (Misc queries) |