(Adds share buy back figure, quote from CEO)

PARIS, July 29 (Reuters) - France's TotalEnergies said on Thursday it would use part of its cash flow for share buybacks worth at least $800 million, as rising oil and gas prices boosted profit, offsetting the hit from selling out of one of its Venezuelan ventures.

TotalEnergies has been investing heavily in clean energy projects and electricity production so it can eventually rely less on oil and gas, mirroring moves by European rivals.

On Thursday it announced a collaboration with Amazon , through which it will supply the online retail giant with renewable electricity, and it has been multiplying new investments, including in areas such as electric vehicle charging.

Surging oil and gas prices are boosting the industry for now, however, lifting earnings and feeding into investment budgets. Royal Dutch Shell and Norway's Equinor also announced share buyback schemes on Thursday, sparking a share price rally.

TotalEnergies shares were up 2.4% at 1500 GMT.

The group said it expected to generate more than $25 billion in cash flow this year, based on current high oil price forecasts, and would invest in more new projects and return surplus amounts to shareholders if oil prices remained high.

"The board of directors decided to allocate up to 40% of the additional cash flow generated above $60 per barrel to share buybacks," TotalEnergies said in a statement.

Chief Executive Patrick Pouyanne told an analyst call that it would mean share buybacks of $800 million in 2021.

"And if the average price is going up to $68 (a barrel), for example – we are not far – it could go up to one billion dollars," he said.

The group said it would also pay a second interim dividend of 0.66 euros per share for 2021, stable from the first quarter.

HYDROCARBON PRODUCTION

TotalEnergies' adjusted net income progressed further in the April to June period, reaching $3.5 billion, compared to an adjusted net income of $126 million a year ago at the start of the COVID-19 pandemic.

But the group also disclosed it was impacted by a $1.38 billion loss on the sale of its 30.3% stake in Petrocedeno, which produces extra-heavy crude oil from Venezuela's Orinoco Belt and transforms it into light crude oil.

Total said Venezuela's state-run oil company PDVSA would become Petrocedeno's 100% owner as Norway's Equinor also agreed to exit its 9.7% stake.

TotalEnergies, which still has a majority stake in Venezuela's Yucal Placer gas field among assets in the country, said the Petrocedeno development was not in line with the low carbon intensity projects it wants to focus on as part of any new oil investments.

The company slightly lowered its hydrocarbon production forecast to 2.85 million of barrels of oil equivalent per day (Mboe/d) in 2021 due to OPEC+ quotas in the second half of 2021. It had previously forecast that production would be stable versus 2020's 2.87 Mboe/d.

It said net investments would reach between $12 and $13 billion in 2021, with half of that earmarked for growth projects, including a major chunk in renewable energy and electricity.

Like its rivals, TotalEnergies has come under pressure from climate campaigners and some shareholders to speed up the shift from fossil fuels to cleaner sources of energy. It has a plan to reach carbon neutrality by 2050, with staggered targets to 2030.

It also faces the challenge of catching up with renewable energy leaders such as Spanish wind power group Iberdrola and Italy's Enel, which have been positioning themselves for years in the segment.

(Reporting by Sarah White, Benjamin Mallet and Sudip Kar-Gupta, Editing by David Evans, Barbara Lewis and Emelia Sithole-Matarise)