Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drag-and-drop to custom task pane in Excel VSTO

Arr, I am stuck!

I'm writing an Excel add-in that opens up a custom task pane (it's a data analysis tool type of thing). In the interest of productivity I want to enable the user to drag an object, such as a file or email attachment, onto a part of that task pane for processing, rather than have to go through one or more file dialogs.

The problem is that Excel seems to completely override the drag/drop properties of the custom task pane and the controls it contains, so that when I drop a file onto the task pane, Excel simply tries to open it as a spreadsheet (and succeeds if it's a supported file type), and my DragDrop event never fires.

Is there any way to make Excel stop doing this so the drop event gets sent to the task pane?

like image 617
ReturningTarzan Avatar asked Apr 14 '11 22:04

ReturningTarzan


1 Answers

Ok, I found a way. It turns out the DragDrop event won't fire as Excel handles all drag events itself, but the DragEnter event does fire, and when it does I can open a modeless form on top of the actual drop target. This form can then receive the DragDrop event (and kills itself on the DragLeave event). It's a bit of a hack, but it seems to be working nicely.

like image 142
ReturningTarzan Avatar answered Sep 29 '22 01:09

ReturningTarzan