I taught my dogs by taking them to places like Petsmart and the park. Find a spot not too close to the action, but where your pup can see people coming and going. As soon as he is interested- ears up, tail ready to wag, but BEFORE he gets silly, wave a smelly treat enclosed in your fist right under his nose, and ask for a sit. He has to stay sitting until the distraction passes. Every time his attention wavers, pass the hand with the treat under his nose again. You can even keep the hand in front of his face, and open the space between your finger and your thumb enough to prompt him to stick his nose or tongue in- just don't give up the treat until the exciting thing is past. If he doesn't hold the sit, correct him for getting up and put him back in position. This not only teaches manners, but it also teaches that when something exciting happens you look to me for directions. Earnest flushed a deer out of some high grass a while back, he ran to me and sat, as he has been conditioned to do anytime something exciting or out of the ordinary happens. You have to read the dog, and ask for the "sit and pay attention" everytime they show that spark of interest in something going by- the idea is to redirect that attention to you. I don't allow greeting people or dogs during this phase, I want the dog to stop anticipating the greeting. As time goes by, they will learn to sit automatically when someone approaches, you can add allowing a greeting then. As far as greeting guests in your home, same thing, they must sit before being petted or allowed to greet guests, use your lead to enforce the rules, if he gets silly he gets a time out in another room. You can try again later, you keep conditioning that the only time the pup gets to see company is if he behaves.