I'm working on a project to detect if a user form is open and if not, close an excel program hidden in the background. The issue I'm having is the if statement in the Function Excel_Form_Close. The if statement works independently and does what it should do but when moved into the function area, the msgbox "Entered" triggers but the If statements do not. Why would the If statement be getting skipped during the load?
Sub Macro_Timer()
CATIA.Application.OnTime Now + TimeValue("00:00:10"), "Excel_Form_Close"
End Sub
Function Excel_Form_Close()
MsgBox "Entered Excel_Form_Close"
If Currentproject.Allforms("USER_FORM").IsLoaded = False Then
Call APP_CLOSE(LIST_APP, LIST_FILE)
MsgBox "Excel Closed"
End
End If
If Currentproject.Allforms("USER_FORM").IsLoaded = True Then
MsgBox "USER FORM CURRENTLY LOADED"
Call Macro_Timer
End If
End Function