Unless you put the python script as a sub event of "Start of Layout" it will be run on the first frame. Everything under "Start of layout" will be run before the first frame. So "Word" doesn't have a value at the start of the layout, hence the error.