The first type of excommunication you're talking about is the automatic kind. If you commit grave (not venial) sins and haven't been to confession yet, you cannot receive Communion without committing a sacrilege. No formal decree from the bishop is necessary for this. In fact, no one even needs to know you committed a sin, for you to be in this state.
A formal excommunication is a public announcement intended to shame a sinner into amending his life and re-entering a state of grace by repentance and confession. I believe in some cases it requires a public act by the sinner, to let the community know that the public charge of excommunication has been answered. So, to contradict your position, a public excommunication is not a shunning but rather is meant to bring the sinner back into the community.
It might be a useful practice for the Church to do more of...