Hello everyone, new guy here.
I'm pulling my hair out as I cannot figure this out, no matter how many threads I read on it or tutorials I watch. Here's how this one works. On open, the app checks a location on the drive for a file of the same name. If its there, the workbook closes. If it's not, it is created and then autosaved every 2 minutes in an endless loop. Im trying to terminate this loop on close of the workbook. The "ThisWorkbook" module calls the "Sheet1" module, which contains the following -
Private CancelSave
Public Sub SaveWb()
CancelSave = DateAdd("n", 2, Time)
ThisWorkbook.Save
Application.OnTime CancelSave, "Sheet1.SaveWb"
End Sub
Public Sub Workbook_BeforeClose(Cancel As Boolean)
Application.OnTime CancelSave, "Sheet1.SaveWb", , False
End Sub
When I have any other workbooks open while I close this, the timer still continues and will open the old workbook up and start all over. I've spent days trying to trouble shoot this and I feel like there is something fundamental that I am misunderstanding. Thanks for the help in advance!
I'm pulling my hair out as I cannot figure this out, no matter how many threads I read on it or tutorials I watch. Here's how this one works. On open, the app checks a location on the drive for a file of the same name. If its there, the workbook closes. If it's not, it is created and then autosaved every 2 minutes in an endless loop. Im trying to terminate this loop on close of the workbook. The "ThisWorkbook" module calls the "Sheet1" module, which contains the following -
Private CancelSave
Public Sub SaveWb()
CancelSave = DateAdd("n", 2, Time)
ThisWorkbook.Save
Application.OnTime CancelSave, "Sheet1.SaveWb"
End Sub
Public Sub Workbook_BeforeClose(Cancel As Boolean)
Application.OnTime CancelSave, "Sheet1.SaveWb", , False
End Sub
When I have any other workbooks open while I close this, the timer still continues and will open the old workbook up and start all over. I've spent days trying to trouble shoot this and I feel like there is something fundamental that I am misunderstanding. Thanks for the help in advance!