At a luncheon sponsored by the American Heart Surgery Association in Detroit on Friday, Rosie O'Donnell revealed that she underwent vertical gastric sleeve surgery, People reports.

Since having the procedure in July, O'Donnell says she has lost 40 pounds and currently weighs 190 pounds.

The weight loss surgery reduces one's stomach size by approximately 25 percent and thereby limitshe amount of food your stomach can hold. "I did it to save my life," O'Donnell, who suffered a heart attack in 2012, said. She also had high blood pressure, high cholesterol and was pre-diabetic.

O'Donnell, 51, also started a healthy diet, which involved a reduced intake of red meat, carbohydrates and sugar. She also increased her exercise by taking daily short walks with her wife Michelle Rounds.

The comedian and former talk show host initially tried to lose weight naturally, but she was unsuccessful. Her doctor gave her one year to lose weight and told her she had to be under 200 pounds one year after the surgery.

"She tried to lose weight but it wasn't working," O'Donnell's spokesperson Cindi Berger tells the magazine. "It was a lifesaving surgery. But it's only a tool, not a cure."

O'Donnell recently showed off her slimmer figure on The View last Friday.