So, I could have just let the system generate the exception, but this would cause problems with other programs that already had been written and did not have the necessary logic to trap the error. So, I found there is an environment variable that can be checked to determine if the program is running in an interactive state. If it is running in an interactive state, you can use the MSGBOX function. And, if it not running in an interactive environment, you can let the object generate an exception
This is the variable to check:
Environment.UserInteractive
If Environment.UserInteractive Then
msgbox("ERROR")
else
throw ex
end if