I've actually come up with a running joke that will make these awkward situations more tolerable... It's easier if majority of your office is male; or crude females.
Whenever someone walks by the door of my office I say: "Hey, come here a second... Can I ask you something? Why is it that everytime I fart, someone walks in here." regardless of if I just farted or not, It gets a smirk with a roll of the eyes and they quickly leave. When I have realy bad gas, I use this joke frequently and people stay away.
Another thing I've used, and this can be tough to talk your way out of if you get caught... but use the stinky chair to your advantage... whenever a co-worker leaves their desk un-attended, I go fart in it so that when they come back and sit down, all that ass matter trapped in the foam padding of the chair is re-released while you're miles away. Warning... this does not work on leather chairs.