I tend to write in all my own error handling anyway. I don't want automated scripts coming to a stop due to an error, because I know they can, and will, happen.
So in your case, I'd put in a check against the top level item you'll be using - the MDIWindow("Sprawa") by the look of it - and if it doesn't exist, drop out of the routine after logging an error.
So inside SprAddModify ...
def SprAddModify(rep,number,year):
if (<top level object is present>) then:
date_w='01012016'
SprReg.SprReg(rep,number,year)
SprAdd(date_w)
SprOpen(rep,number,year)
SprCheck(date_w)
else:
Log an error
Return
(Syntax and formatting are not correct .... it's just example logic)
Like I say, I tend to have all the automatic error stopping switched off and rely on my own error handlers. My scripts have always had loads of error handling and validation built in anyway as they are keyword + data driven by other users. Which means there is tons of scope for the user to introduce bad calls and/or data so it has to be able to cope with pretty much anything.
It's more work, but it's also more robust once that work is done.