same problem..all you can really do is try to get there attention with something else
like a frisbee or a ball or food,
dangle it in front of there nose, get there attention and they'll focus on that
or just keep them on a leash close to you, and if they start barking, hit them on the head and tell them no.
or do soemthing to distract them. like as soon as they start barking, jump in front of them and start playing with them, get them wound up to play with you, so they arent focusing on anything else.