ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   code reopens file (https://www.excelbanter.com/excel-programming/397432-code-reopens-file.html)

AJB

code reopens file
 
The following code tries to reopen my files 30-45 seconds after I close them.
Any ideas what might make it do this? The code is meant to track my time in
the different bids I work on

Thanks,

Andy

Code in module:
Public Sub StartCounting(Optional bStart As Boolean = False)
Const dINCREMENT As Date = #12:01:00 AM#
If Not bStart Then
With Sheets("Bid Summary").Range("J3")
..Value = .Value + dINCREMENT
End With
End If
dNextCall = Now + dINCREMENT
Application.OnTime dNextCall, "StartCounting", Schedule:=True
End Sub

Public Sub StopCounting()
Application.OnTime dNextCall, "StartCounting", Schedule:=False
End Sub

Code in workbook:
Public Sub StartCounting(Optional bStart As Boolean = False)
Const dINCREMENT As Date = #12:01:00 AM#
If Not bStart Then
With Sheets("Bid Summary").Range("J3")
..Value = .Value + dINCREMENT
End With
End If
dNextCall = Now + dINCREMENT
Application.OnTime dNextCall, "StartCounting", Schedule:=True
End Sub

Public Sub StopCounting()
Application.OnTime dNextCall, "StartCounting", Schedule:=False
End Sub

Jim Rech

code reopens file
 
Unless you are closing Excel you have to call the StopCounting routine
before you close the workbook, else Excel looks for the macro you scheduled.

--
Jim
"AJB" wrote in message
...
| The following code tries to reopen my files 30-45 seconds after I close
them.
| Any ideas what might make it do this? The code is meant to track my time
in
| the different bids I work on
|
| Thanks,
|
| Andy
|
| Code in module:
| Public Sub StartCounting(Optional bStart As Boolean = False)
| Const dINCREMENT As Date = #12:01:00 AM#
| If Not bStart Then
| With Sheets("Bid Summary").Range("J3")
| .Value = .Value + dINCREMENT
| End With
| End If
| dNextCall = Now + dINCREMENT
| Application.OnTime dNextCall, "StartCounting", Schedule:=True
| End Sub
|
| Public Sub StopCounting()
| Application.OnTime dNextCall, "StartCounting", Schedule:=False
| End Sub
|
| Code in workbook:
| Public Sub StartCounting(Optional bStart As Boolean = False)
| Const dINCREMENT As Date = #12:01:00 AM#
| If Not bStart Then
| With Sheets("Bid Summary").Range("J3")
| .Value = .Value + dINCREMENT
| End With
| End If
| dNextCall = Now + dINCREMENT
| Application.OnTime dNextCall, "StartCounting", Schedule:=True
| End Sub
|
| Public Sub StopCounting()
| Application.OnTime dNextCall, "StartCounting", Schedule:=False
| End Sub




All times are GMT +1. The time now is 03:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com