That's how I trained all of my cats. You can also try putting a couple of pennies in a soda can. Everytime the cat goes to scratch something he shouldn't, shake the can. They HATE loud noises. The key is you need to squirt or shake the MINUTE the cat does something bad. Not an hour or even minutes later because they won't remember why they're being punished.

I train kittens by yelling "NO!" very loudly, then take them over to the scratching post or scratching box, take their from paws and do a scratching motion with them to show them HOW.