Drag-and-drop to custom task pane in Excel VSTO
Asked Answered
K

1

6

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?

Khaddar answered 14/4, 2011 at 22:34 Comment(0)
K
5

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.

Khaddar answered 18/4, 2011 at 8:56 Comment(1)
Hi. Is the form you open visible to the user? I'm also having the same problem, so I'd love to see the code you came up with.Yammer

© 2022 - 2024 — McMap. All rights reserved.