Forget the swatting! Putting aside the moral reasons not to swat, physical action will only hype them up and they will never learn.
I admit, this is something I still struggle with my boys on when the doorbell rings, in the car, and certain triggers on our walks. However, they do not yap randomly.
1. How much exercise do they get? A dog with pent up energy is much more likely to bark. A daily routine of activities helps calm the dog. My boys know when to expect certain things like meals or short play sessions, and their favorite part of the day -- a big outing with a long walk.
2. Try pennies in a can. If they are immune to this, try other noise makers to see what gets their attention. There is a dog behavior product, can't think of the name, that is nothing more than a can of compressed air. It makes a "Shhhh!" sound. Never point anything like this right at the dog.
Here are more tips:
http://www.yorkietalk.com/forums/gen...h-barking.html