Contributed with the help of Karen L Overall of the Centre for Neurobiology and Behaviour, Psychiatry Department, University of Pennsylvania School of Medicine.
There are many causes for this behaviour. Separation anxiety, craving for attention and even the doorbell can cause the most placid dogs to bark inappropriately.
When trying to discourage inappropriate barking it is important that you know the reason for the barking. Some dogs bark at the doorbell in protection of their pack (the family). It is important not to discourage the desire to protect the family, but allow the dog to associate the doorbell with good things. Practice this by inviting friends over to ring the doorbell. Correct any barks with a firm 'no' and allow your friend to reward the dog when he resists temptation to 'warn you of intruders'.
Dogs that suffer with separation anxiety should be treated for that before any barking issues are addressed as barking is a symptom of it rather than a result.
The key to dealing with dogs that bark for attention is patience and the ability to be on hand to reward good behaviour. It is ineffective to reward a dog for simply not barking, unless that reward is an alternative to the undesirable behaviour.
Again, your friends can help with this. Get a friend to sit with the dog as you 'leave the house'. Your friend can distract the dog with the treat and also positively reinforce the no barking rule. Only return to your dog when he has successfully completed a designated period of not barking. As soon as the dog barks, your friend should leave the room. Then try it without your friend. Simply leave a few treats with the dog on his own. Do not return to him if he barks. If he continues to bark return to the dog, issue a 'no' and leave, offering no attention or physical contact.
Dog Training & Behaviour - All You Need to Know