During the Time War he would have used guns all the time, so his aim would've been excellent. (He explicitly said that he 'was a soldier' in the past.)
He might have also had to train with guns at some earlier point—many people who were forced to do target practice at school, or grew up in countries with a universal draft, end up being pretty good shots despite not liking guns. More generally, just because one hates guns doesn't mean one can't be proficient in their use. Many soldiers hate guns but know how to use them, obviously. Even Sarah Jane Smith, who also detested guns, was a good shot when she used one (The "Pyramids of Mars"), and much later in The Sarah Jane Adventures, she referred to the training she'd had during her time with UNIT.
Finally, the Doctor's hatred of guns may not always have existed - see "The Gunfighters".