I had running without problems this code in a window open event script until I upgraded from 7.6.1 to 7.6.2 and the following error appeared:
Can it be a new bug?
Can you post the entire stack trace for the error, you can do this by selecting full on the bottom of the error message box.