Bishan
Bishan

Reputation: 15740

Call a function after User delete Excel Work Sheet in C#

I am using Microsoft.Office.Interop.Excel and I need to call a custom function when User delete a Excel Work Sheet (Right click on sheet name and delete).

How can I access the Work Sheet delete event?

I found WorkbookEvents_SheetBeforeDeleteEventHandler in Microsoft Docs, but I'm looking for something like AfterDeleteEventHandler.

How can I achieve this?

Upvotes: 0

Views: 179

Answers (1)

Eugene Astafiev
Eugene Astafiev

Reputation: 49445

If a worksheet is deleted another sheet becomes an active one, so handling the Workbook.SheetActivate event can help. It is fired when any sheet is activated. In the event handler you may check whether a "deleted" sheet still exists or not.

Upvotes: 1

Related Questions