My first post here. I have dome some VBA scripting in Visio 2016. The script has certain variables, user selected parameters and script generated data like random numbers, file names etc. Most of them changes on each iteration. Process iterates for a large number of times as user selected. Sometimes for more than a thousand iteration on user selected. Whole iterations may take three to four hours to complete.
Working fine.

I want to have additional facility:

I want flush (write) crucial data as variable values, user selections, script generated data right at a moment, store on secondary storage HDD or wherever.

This will help me to close and restart the script from the place from where it was stopped.
Currently there is no option to pause or stop script in the middle otherwise script have to start over again.

Other reason compelling me to do it for example are if Systems hangs for a hardware fault, glitch in electric power, blackout, brownout etc. etc. ...

Please give me some hints/pointers how can I write my crucial data on HDD etc. on the fly. at specific intervals, say after completing one loop or at any other event.