Is it safe to take vicodin while pregnant?

Yes, but... We do try to avoid narcotics when we can. Vicodin has a narcotic and tylenol (acetaminophen) in it. The narcotic does get to the baby a bit. Babies born after mom has been on a narcotic every day for a while do go through a withdrawal. So we try to avoid it, especially long term. But for an acute pain, it is safe in pregnancy.
How much, how often? If there is an acute injury, like an ankle sprain or some such, use of a few vicodin (acetaminophen/hydrocodone) is not dangerous to you or the baby. However, regular use of vicodin, like any other opioid, will result in physical dependency both for you and your developing child. Children born to mothers on opioids may require being withdrawn in the hospital, which can take weeks or even months.