Private Function IsExecutable() As Boolean
On Error GoTo PROC_ERROR
Debug.Print 1/0
IsExecutable = True
PROC_EXIT:
Exit Function
PROC_ERROR:
IsExecutable = False
GoTo PROC_EXIT
End Function
The function is based in the fact that the Debug method only executes within the IDE envinronment. When the program is compiled the calls to the Debug method are omitted, so the code falls through and the IsExecutable = True statement is executed.
Within the IDE, the Debug.Print 1/0 is executed and provokes an error. Control is then switched to the PROC_ERROR label, which subsequently sets the IsExecutable = False
_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.