The output of the MS Word report is set in "sub terminate". When terminating - exiting the form with the "X" button, a "sub terminate" is also executed. How can I disable this?
I'm working on an old case and I don't know why the output is written in sub terminate?
Simple answer: You can't.
There are code parts that are ALWAYS executed. For any LotusScript-Container this is "Sub Initialize" when it is loaded and "Sub Terminate" when it is unloaded.
For e.g. a form there are events like "QueryOpen", "PostOpen", "QuerySave", "PostSave"... etc. as well: You can't stop these events from executing as well.
Now if your code is in Sub Terminate but you do not want to execute it when the window closing "X" button is pressed, then you need to set a flag somewhere. And if this flag is missing: Don't execute.
You could choose global variables, document item values or environment variables to determine if the code should be executed:
I'll show one example with a global variable:
In (Declarations) put:
In your Terminate you wrap your existing code:
Or you exit (if you do not like the indentation of the additional if:
Now whenever "x" is clicked nothing happens.
If you have a button that should trigger the code, then use this inside of the button:
That should do the trick. As said you could also use document items or environment variables to do the trick: