Are you getting any error messages? If so, what are they?
If not, then what are you basing your statement of it not working on?
I tested Riamus' code, after you posted that it's not working, and it worked for me exactly as it should.