Here's some information on handling unexpected windows:
https://support.smartbear.com/articles/testcomplete/handling-unexpected-windows/
If the errors are always in the same place, so not really "unexpected", then you can always insert code to directly handle them, such as checking for the text in the format error you mentioned and if it exists, then click OK or whatever will dismiss it and let you continue.
This will make your script run, but it's usually better if you clean up what's causing the errors in the first place. For instance, duplicate file names can be handled by making a saved file have a unique name every time. We can make suggestions for this clean up if you let us know what's going on with your errors.