none
Visio, Excel: OLE Drag Drop RRS feed

  • Question

  • We are developing an AddIn which should be able to Drag&Drop custom objects from our application onto a Visio drawing. To do that, we store some object information as a string in a DataObject, the AddIn should then deal with that string and perform custom actions if it was recognized. This works fine when we open Visio and the application side by side, we can Drag & Drop to Visio, the ShapeAdded event is fired and our custom string is shown on the drawing.

    However, if we attempt to open the very same application (or merely the relevant control) from within the VSTO AddIn, everything appears to be fine, but Visio doesn't react to the Drag&Drop operation anymore. No event is fired (checked in the event monitor) and the drop is blocked. We already checked all possibilities and made sure that the very same code is called on our side, which is the case, but now we are pretty much stuck since we can't look into Visio's internals.

    Any help is greatly appreciated!

    Add: we experience the very same behavior when we instantiate that control in an excel AddIn (Custom Task Pane), so it seems to be a general problem.

    Br,

    Juergen


    Monday, March 19, 2012 10:52 AM

Answers

All replies

  • Hi Juergen,

    Thanks for posting in the MSDN Forum.

    Would you please clarify your Office version and Visual Studio version for further research?

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, March 21, 2012 6:13 AM
    Moderator
  • Tom,

    thanks for your answer! we're working with Office 2010 64bit and VS2010. In the meanwhile we somehow made it work, using OemText as the only DataFormat passed to SetData. The weird thing is, as soon as we pass a different format or even an additional format to OemText  (i.e. StringFormat or Unicode) it will block the D&D again - that's at least the case for Visio, Excel on the other hand seems to be fine with multiple formats. So we made the event trigger for now (as described above) which was the crucial task, but it's not really transparent to us what to do and what to avoid - that was just the result of two days try&error.

    So any general guideline would be much appreciated!

    Br,

    Juergen

    Wednesday, March 21, 2012 4:44 PM
  • Hi Juergen,

    You report a very interesting problem and an intriguing solution. Short of giving you guidlines based on experience or known content you might consider whether your object falls in the stencil category or some other that woulfn't apply to Excel, and if not, does that make a difference - are you dropping it on a stencil or on the drawing? There might be something in the following list of MSDN content that can give you some insights in how to proceed now that you have a workaround for your own current issue.

    DataFormats Class (System.Windows)
    http://msdn.microsoft.com/en-us/library/system.windows.dataformats.aspx

    DataFormats.OemText Field (System.Windows)
    http://msdn.microsoft.com/en-us/library/system.windows.dataformats.oemtext.aspx

    DataFormats.Text Field (System.Windows) - MSDN – Explore ...
    http://msdn.microsoft.com/en-us/library/system.windows.dataformats.text.aspx

    DataFormats.StringFormat Field (System.Windows)
    http://msdn.microsoft.com/en-us/library/system.windows.dataformats.stringformat.aspx

    DataFormats.FileDrop Field (System.Windows)
    http://msdn.microsoft.com/en-us/library/system.windows.dataformats.filedrop.aspx

    Regards,
    Chris Jensen
    Senior Technical Support Lead

    Chris Jensen

    • Marked as answer by Bruce Song Wednesday, April 4, 2012 7:03 AM
    Wednesday, March 21, 2012 6:03 PM
    Moderator
  • Thanks Chris, I'll have my guys look into it even though I suppose they're already familiar with it. As our Visio project is still in the very beginning we'll keep investigating anyway and let you know if any conclusive theory comes up!
    Thursday, March 22, 2012 8:17 AM