If you want to keep your dog from barking while you're away, you're going to need to address the reasons why your dog is barking. Dogs will bark for two reasons: they're separated from you (their pack) and they are on alarm mode (they detect a stranger). It's understandable. Dogs have been bred for generations to bark to warn us; it's their job. It takes a lot of work to avoid this kind of behavior.
Desensitize Your Dog to Your Absence
Many dogs panic when you leave because they aren't certain when you're going to come back -- and because they hate it when you leave. Desensitize your dog by repeatedly leaving throughout the day and immediately coming back. Eventually your dog is going to realize that you're definitely coming back. Every time you leave and come back, you should ignore your dog. Do not talk to your dog before you leave or greet them when you arrive. The goal is to get your dog to see you leaving as "no big deal."
Consider Crating Your Dog When You're Out
If your dog gets stressed out when you're gone, they could be experiencing something called separation anxiety. A crate will help. Crates are wire kennels, and though it may seem mean to use them, they're actually very soothing for your dog. Place a dog bed and blanket in the crate, and then let your dog get used to it without closing it. Your dog will eventually adopt it as a safe place, like a "den." You can then put your dog in the crate when you're gone and cover it with a blanket so that your dog feels comfortable. (Always leave your dog with water and never use the crate as punishment.)
Teach Your Dog to "Speak"
Teaching your dog to "speak" is often the first step towards directing your dog to stop barking. After you teach your dog the command to "bark," you can also teach them the command "quiet." This is done by giving them a treat and saying the word "quiet" immediately after they stop barking. Once you've successfully taught them the term "quiet," you'll be able to direct them to be quieter when they start barking while you're at home.
There are many mechanical devices designed to keep dogs from barking: "stimulation" collars, "control" collars, citronella collars and more. Most veterinarians and dog trainers discourage the use of these devices. They can lead to neurotic behavior and physical harm in pets. Always approach a dog training expert, like those at Canine Behavior Center, before you resort to more desperate measures, as they have the experience to help you and your dog.