Where does you put the code (into Excel or Word) ..?
I suppose you put it into excel so as to add the Word Library

Make sure of References from Tools menu ...