Jan Hus at the Council of Constance
Excommunication is not as easy to get as some might think whether they like it or not. Canon law does have regulations for who can get an excommunication either latae setentiae or ferendae setentiae.
First off you have to be at least 16 years old ; second, you have to be mentally capable of knowing right from wrong ; third, you had to willfully commit the act without threat or force from another person. These are some requirements necessary for a person to receive excommunication.
A person who rejects certain aspects of the faith but does not know they are part of the faith is only in material heresy, so still members of the Church. However, a person who willfully and/or obstinately rejects certain articles of the faith, especially after being informed they are going against Church dogma have placed themselves outside of the Church via latae setentiae excommunication . This means a person who has been excommunicated may not receive Holy Communion from a Catholic priest in full communion with the Holy See, hold ecclesiastical office in the Church or hold any role in Catholic ministries . An excommunication is lifted once the excommunicate has been absolved in Confession by a priest. Once the excommunication has been lifted, the individual may once again receive Holy Communion and other Sacraments, hold ecclesiastical office and/or Catholic ministries.
Having said that, the rarity of excommunication is no excuse to commit sinful acts or scandalize the Church, which is why excommunication exists in the first place. A number of Catholic politicians embrace material heresy in regards to abortion, euthanasia and same-sex unions to name a few: such include Nancy Pelosi, Joe Biden and John Kerry. Not only do they support these things, but at least in some instances (like Pelosi’s) they actually claim they are condoned by the Church. This is pure scandalous because it leads others to think they can participate in the sacramental life of the Church and indulge in grave sin. If they think they can receive the Sacraments while in grave sin, then they are not learning anything, and this is why clergy have refused the Sacraments to certain public officials who openly taught in defiance of the Church. Jesus Christ said if your brother does not listen to the Church, then he must be treated as a tax collector ; since then the Church has excommunicated and absolved many for their scandalous acts; Saint Paul said one must break off contact with a heretic  and that he set aside Hymenaeus and Alexander for a while so that they may be purified .
The Church clearly condemns direct abortions and canon law says whoever procures a complete abortion incurs a latae setentiae excommunication . This however, this needs to be taken into context with Can. 1322-1323, since it is not uncommon for a woman to have an abortion due to fear that she cannot provide for the child, afraid of what her family, friends, or teachers might think, or because of a rape or threat that convinces her to have an abortion against her will. Though a direct abortion is intrinsically sinful, the Church is understanding and merciful in the plight of these women and hopes they will come in repentance to a priest. Such a canonical decree goes particularly against abortion doctors who made a business of killing the unborn, are not suffering in the kind of way those pregnant women do, and who are in the stance to provide them other options but instead chose to terminate an unborn human’s life which can also later cause deep emotional stress in women later as I mentioned in a previous article.
 Can. 1323
 Can. 1322
 Can. 751
 Can. 1331
 Matthew 18:17
 Titus 3:10
 1 Timothy 1:20
 Can. 1398