0

I have a very simple code below that works to run a macro at a set time. The issue I'm having is that if the workbook is closed, it will reopen itself to run the macro at the correct time. The only way to stop it is if the computer had been turned off/restarted. I have seen some answers to similar issues but I haven't fully understood the answers as my experience with VBA is very limited. They also had more code in their ontime request so I'm hoping that my issue might be a more simple fix. Any advice would be greatly appreciated.

Private Sub Workbook_Open()



    Application.OnTime TimeValue("08:10:00"), "ButtonRefreshDays"



 End Sub
Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
Chris
  • 21
  • 1
  • 1
  • 2
  • As far as I know, just by closing the whole instance of Excel will stop it, if you don't want to do it... I don't know how to stop that. – Damian Aug 28 '19 at 10:38
  • You can use windows `Task scheduler` to trigger `VBS` file which has code to open Excel file – arun v Aug 28 '19 at 10:53
  • Why not adding statement ? `If Workbooks("....").IsOpen then ` your code `Else` – p77u77n77k Aug 28 '19 at 13:56
  • Does this answer your question? [Application.OnTime running when it shouldn't](https://stackoverflow.com/questions/27005522/application-ontime-running-when-it-shouldnt) – feetwet Jan 07 '21 at 02:38
  • Answered [here](https://stackoverflow.com/q/27005522/2662901), and [here](https://stackoverflow.com/q/45458979/2662901), and [here](https://stackoverflow.com/q/50273166/2662901) ... – feetwet Jan 07 '21 at 02:39

0 Answers0