We recently had a baby and when company comes over, my dog barks when I go near our baby. It's almost as if he wants all my attention. If I leave the house, and the company is still there with my husband, he is fine. If I am holding the baby, he is fine. It's only when I am not holding the baby and we have friends or family over. Why is this happening? It's become a real problem since my mother-in-law is over a few days a week to watch our child. I can't go and see my baby because my dog is practically harassing me by barking nonstop. Does anyone else deal with this or know what I could do to stop him from this behavior? Just for context - I have a 10-year-old Yorkie.
The question why is almost impossible to answer over the internet, but many dogs get overly protective of new babies. I'd have to watch your dog to see what might trigger him. If you cannot improve the situation on your own, you should consider hiring a local dog trainer who can do just that and teach you how to act around your dog to avoid the barking.
But I'm certain that this kind of behavior is unacceptable. The problem with Yorkies is that they are small and people underestimate them. Ask yourself: if your dog was a full-grown German Shepherd, what would you do if he behaved the same way?
I propose you train him to go into his crate or dog bed. You cannot only do it when he starts barking, because he'll see the training as a punishment. Instead you need to repeat the training several times a day at random times and always reward him with a treat if he complies. That forms a positive connection to the crate/bed.
Then, when you have guests and you want to look after your baby, you should send your dog into the crate and close the door before you approach your baby. If you don't have a crate, it might be necessary to put your dog on a leash and fasten the leash very close to the dog bed so he has to stay there. You need to do that before interacting with your baby to keep your dog in a positive mindset when sending him away. If you did it after interacting with your baby, your dog is in a negative mindset (hence the barking) and will probably just ignore you.
When you interact with your baby, you should completely ignore your dog. Don't look at him, don't talk to him, don't even scold him for his barking. His tasks in this family does not involve the baby in any way and he's not allowed to protect the baby. That's your job.