Excommunication is done only upon knowledge that a person has committed a very grave sin. Contrary to what someone above posted, not every Priest can lift all excommunications.
Excommunications means that a person has been “cast out”. They have sinned so greatly that they are no longer considered to be among the human beings that can be saved, unless they do something to get that excommunication lifted.
As an example, any Catholic that has an abortion is automatically excommunicated. Their Parish Priest, may, if allowed by the Bishop of that Diocese, lift that excommunication as the person seeks the Sacrament of Reconciliation. But, in some Dioceses, only the Bishop can lift that excommunication
However, any Catholic that performs an abortion may NEVER be forgiven by a Priest. They MUST have that excommunication lifted by the person that pronounced it, or by their successor (if that Bishop has died or retired). This excommunication is automatic, and is officially pronounced by the Bishop of the Diocese in which the person performed the murder (and yes, they can be excommunicated in more than one diocese, and an excommunication is binding world wide).
If the Pope excommunicates a person, generally only the Pope can lift it. As an example, Henry VIII Tudor was excommunicated by the Pope, and no Priest, Bishop or Cardinal could lift that excommunication.
If a person is excommunicated, and they continue to practice their faith by attending Mass, going to confession/reconciliation, receiving the Eucharist, etc., they are piling on mortal sin after mortal sin.
In the old days, it did indeed involve not only shunning, but total barring from anything to do with the church. No alms, no care, the person was not even allowed to enter a church upon pain of death. A good Catholic could not, and would not, speak to a person known to be excommunicated. While this did not disolve the bonds of matrimony, a Catholic spouse was not to have “carnal relations” with the excommunicated person.
It is a bit less drastic today. However, an excommunicated person may be barred from entering a church, and they are barred from any public appearance at any religious service.
If you die, while still under excommunication, the teaching of the church is that you can not go to heaven. This comes under the power that “whatever sins you do NOT forgive on earth, are not forgiven in heaven”. It is not a light thing to be excommunicated, it is a very, very grave matter to be excommunicated.
It means that your sins go WAY beyond the normal, and you have removed yourself from the Body of Christ by your actions.