Excel VBA script aware of being opened interatively or from the command line

I have a Excel VBA script that automatically runs when opened, extracts one table from a Microsoft Access Database, saves it as CSV, closes it, extracts another, saves it as CSV, closes it, then terminates itself.

Is is called from a short .bat file using the /e option so that Excel does not fully open. The bat file is created on the fly from a JMP/JSL script (JSL from SAS lacks the native ability to equerry access databases).

It works but I am trying to make it idiot proof.

For the sake of the end user (and for me making modifications to a script that closes itself), I'd like the script to be aware of whether it was opened in an interactive Excel session vs. being invoked from the command line (or invoked with the /e option). I want the extraction to run only if invoked in a non-interactive session. If opened in an interactive session, I want to show a help worksheet instead that explains what the script does and where the user should install it.

I cannot figure out anything I can have the script test to make the script be aware whether it is running interactively or non-interactively.

Mike

It may be possible to detect it by tracing parent processes. If cmd.exe is in your ancestry, you are running from a terminal. In UNIX, one might find in batch there is usually no /dev/tty (but ssh and expect can create a pseudo tty).