Hi there: Horses that are "barn sour" or "herd bound" do this because going further away from the security of the other horses makes them nervous. Instead of smacking the horse (which will only make the situation worse), turn her around and let her go back about 25' and then stop. Interrupt the thought processes of the horse by sidepassing a few steps (if she knows how to do this) or ask her to walk over to a few things and put her nose on it. As long as she remains calm, ask her to move forward a few steps, and do the same thing.
Forcing a horse to give more than they are ready for is a big mistake, because that's when they will escalate their dangerous behaviors, like rearing. If you can begin to recognize her thresholds and use approach and retreat, she will start to feel less anxious, and offer to go further and further away from her herd-mates.
It is important to retreat a good distance back so that she knows that you recognized that she was getting emotional. Allowing her to retreat, will give her less incentive to blow up if she's thinking about it. Eventually, you won't need to retreat at all - just stop and play around to make sure she stays on your aids.
Work on the baby steps of building confidence. If possible, do this alone - just you and her - avoid going out with other horses. If you are young, have an adult walk on foot with you. Your horse has to know that her confidence comes from you - not from the other horses at the barn. The problem will never go away if you don't tackle the problem on your own. You might want to take her for a walk on foot one day, and ride her away the next day. Keep switching your strategy.
Another thing to consider - isolation from the herd for a minimum of 3 days, but longer if the horse continues to whinny and run the fence. Isolation means just that - out of sight, out of hearing, out of smelling distance. If this isn't possible; out of sight is the next best option. Herd-bound behavior is on the same emotional level as a foal getting weaned from it's mother. Isolation will accelerate her bond with you.
There is a video rental service online called YourHorseMatters.com It's a cheap alternative to rent instead of purchase, but they have all the dvd sets from Anderson, Parelli, etc. You might want to rent some dvd's and learn some different techniques.
Best wishes for you and your horse.