I have a workbook with multiple buttons. Each button opens up a separate form. Also, I have a macro run in the background every minute or so using:
My problem is, when a form is visible and the macro runs in the background I get an error. So as a workaround I added a check to see if any forms were visible when the program in the background runs. If a form is visible then I exit the background program and try to run it again every 10 seconds or so until the form is no longer visible. I check to see if the forms are visible using
This kind of works, but it breaks down when another workbook is open and I'm not sure why. Any ideas? I would like to not use the work around if possible, but if anyone knows how to fix this, that would be great as well.
thanks!
-Jon
Code:
Application.OnTime
Code:
If FormName.Visible Then
RunWhen = Now + 10 / 86400
RunWhat = "AutoRun"
Application.OnTime EarliestTime:=RunWhen, Procedure:=RunWhat, Schedule:=True
Exit sub
End If
This kind of works, but it breaks down when another workbook is open and I'm not sure why. Any ideas? I would like to not use the work around if possible, but if anyone knows how to fix this, that would be great as well.
thanks!
-Jon