When and for what reasons does the Pope have the right to legitimately excommunicate members of the Church? Please explain me the teaching of the Church on the subject of validity of papal excommunications.

I’ve met one priest who holds that popes can only excommunicate members of the Church for real and grave reasons, and any excommunications for absurd, political, not genuine, or otherwise non-substantiative reasons is null and invalid, even if officially declared by the Pope.

Is such a statement correct? Are there any official documents on the subject?

Or is it true that the Pope can legitimately and effectively excommunicate any member of the Church for whatever reason?

In such a case, is the following excommunication valid and is anyone who mentions in a word or thought Pope Alexander VI in danger of excommunication, or maybe even has already incurred excommunication latae sententiae?

Because, according to Wikipedia, Pope Julius II said:


  I will not live in the same rooms as the Borgias lived. He [Alexander
  VI] desecrated the Holy Church as none before. He usurped the papal
  power by the devil's aid, and I forbid under the pain of
  excommunication anyone to speak or think of Borgia again. His name and
  memory must be forgotten. It must be crossed out of every document and
  memorial. His reign must be obliterated. All paintings made of the
  Borgias or for them must be covered over with black crepe. All the
  tombs of the Borgias must be opened and their bodies sent back to
  where they belong—to Spain.
One must be tried and judged guilty to incur a ferendæ sententiæ excommunication.
In that quote you give, where it says &quot;I forbid under the pain of excommunication…,&quot; this refers to the conditions of a ferendæ sententiæ excommunication. One &quot;incurs it only when the judge has summoned him before his tribunal, declared him guilty, and punished him according to the terms of the law.&quot; (source).
Some Background on Excommunications
For those Catholics in his jurisdiction, a bishop can

perform a ferendæ sententiæ excommunication

or

declare that someone has excommunicated himself by having performed the excommunicable offense itself, in the case of latæ sententiæ excommunications.

For a recent example of latæ sententiæ excommunication that the bishop publicly acknowledged/declared, see the 2010 excommunication of Sister Margaret McBride of Phoenix, Arizona.


See also: &quot;Who can excommunicate?&quot;
However, a superior can annul the excommunication of an inferior, as then-Card. Ratzinger, prefect of the Congregation for the Doctrine of the Faith, did for Bp. Joseph Ferrario's excommunications of the so-called "[Hawaii Six][4]" in 1991. Here is Cardinal Ratzinger's letter:


Now, a pope has no superior, save God alone. However, a subsequent pope can lift excommunications, as Benedict XVI did in 2009 for the Society of St. Pius X bishops whom John Paul II declared excommunicated in 1988.