what is the error you get. You are probably trying to reach a property which is for some reason undefined at this time or the object is not valid.
Your capture makes my point. You get that error because at some point some property is not defined as the property owner is probably not valid at this time.
As you are using ESTK, you should open the data browser and inspect the object chain until you can determine what object is causing the error. Then you should understand easily why.
the problem was already tackled years ago by Gerald Singelmann (all in German):
Gerald said, that his script spaltenbreite_nach_längster_spalte.jsx is a "study" and could fail in various constellations of text formatting. For the easy ones it should work as expected.
A discussion at hilfdirsselbst.ch on the topic (all in German):