InIDE


Description:
This can be called to determine if a program is being run from within the IDE. Usage should be straightforward.
 
Code:
Public Function InIDE() As Boolean

    Static bRun As Boolean
    Static bIDE As Boolean

    If Not bRun Then
        bRun = True
        On Error Resume Next
        Err.Clear
        Debug.Print 1 / 0
        If Err Then
            bIDE = True
        Else
            bIDE = False
        End If
        Err.Clear
        On Error GoTo 0
    End If

    InIDE = bIDE
    
End Function
 
Sample Usage:
 
    If InIDE Then
        MsgBox "This is running from the IDE"
    Else
        MsgBox "This is running outside the IDE"
    End If