Application.ontime - still stuck :F

thorpyuk

Well-known Member
Joined
Mar 14, 2006
Messages
1,453
Hiya,

I have a spreadsheet that looks like this:

pic.jpg


I want to bring up a prompt whenever now() is equal to any of the date / time combinations in column L, regardless of where in the spreadsheet I am working. (or even better, regardless of which application I am working in). The spreadsheet will always be open...

I've tried this code in the workbook_SheetSelectionChange module, but it does not work & gives me an error:

Code:
If Application.OnTime = Sheets("Callback").Range("L25").Value Then
    MsgBox "Please contact " & Sheets("Callback").Range("B25").Value

Please can anyone help? Thanks
 
*hoik*

Ok, no problem. It's not a biggie, because you can close it by shutting excel down, as opposed to just the individual spreadsheet....
 
Upvote 0

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
*bounce*


If you're reading this for the 1st time, I have some code that does a wonderful job of bringing up a message box based upon a time I specify, but I now have the problem that excel wont close if I click the 'close spreadsheet' button, as it re-opens again!
 
Upvote 0
Code:
  Private Sub Workbook_BeforeClose(Cancel As Boolean) 
       CancelOnTime 
  End Sub

Code:
Private Sub Workbook_Open()
      SchdlOnTime
End Sub

Hi

If you've got CancelOnTime in Module 1 then try changing the code to;

Code:
Module1.CancelOnTime

And

Module1.SchdlOnTime

Not saying it will help, but you said (somewhere) that part failed.

Your Workbook is probably reopening because an Ontime event is being fired which would cause it to reopen, you need to make sure that the events are cancelled in the Workbook_BeforeClose section.
 
Upvote 0
Hi JazzSP8,

No, it's all within the workbook module...

This is the code for cancelontime:

Code:
Private Sub CancelOnTime()
       Application.OnTime RunNextTime, "ThisWorkbook.CallBackProcessor", False
  End Sub

This is the code for workbook_beforeclose:

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
CancelOnTime
   With Application
       .EnableCancelKey = xlDisabled
       .ScreenUpdating = False
        
       Call HideSheets
        
       .ScreenUpdating = True
       .EnableCancelKey = xlInterrupt
   End With

End Sub

The other 'blurb' is based on someones code for forcing people to enable macros, but cancelontime should run before that, so it shouldn't have any effect...
 
Upvote 0

Forum statistics

Threads
1,215,222
Messages
6,123,704
Members
449,118
Latest member
MichealRed

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top