views:

23

answers:

1

Hi all,

I have a VSTO add-in for Excel 2007 and need to figure out a way to disable two types of events in the Excel: deletion of worksheets and repositioning of worksheets. Ideally I could just handle the event, pop a message to the user indicating the function is disabled, and cancel the action.

Does anyone know if this is possible through VSTO? I have searched around and found nothing on this topic.

Any help is appreciated.

Thanks! Jim

A: 

I have bad news for you. The Excel object model doesn't expose events for the deletion of a worksheet, and I would be surprised it did for a worksheet repositioning. The links below are the events available on Worksheet and Workbook, and as you will see, while you have hooks for additions, the deletions are sadly missing. BTW, this is not a VSTO-specific problem, the same issue exists in VBA.

http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.worksheet_events.aspx

http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.workbook_events.aspx

Mathias
I was beginning to suspect as much. Thanks for the reply, Mathias.
Aggnaught
Sorry to be the bearer of bad news :( I can understand why the repositioning is not there, but it still puzzles me that the deletion related events are missing.
Mathias