Welcome to VBForums

That error means that you put the code in the wrong place - it needs to go in the "General" -> "Declarations" section, which is at the very top of the code file.