Share via


Drag and Drop Business Objects into Word/Excel 2003/2007 Surface

Many a times we may need to drag drop business objects from custom pane(Addin/document level project) or Hosted application to Word surface.

Consider a Tree Control having multiple nodes and different kinds of business objects. These business objects may need different kind the automation tasks when dropped at a particular location inside word surface. These drops also may need to validate location of the drop and allow or disallow the same.

There is no direct way to have this feature.  We must apply a workaround to achieve the same. I will try to explain how we could do this for a WPF/Windows application hosting Word internally. Below are the steps :

  1. Create a WPF/Windows application to host Word application.

  2. Reference the all the PIA's in the custom app.

  3. Create a Editor class and attach selection change event to a delegate.

  4. Create a static class to hold the global drag drop state and object.

  5. image

     

  6. Implement the selection change event as shown below

  7. image

     

  8. Implementing process drop

  9. image

     

  10. Assign the GlobalDragDropElement in before drag event of the control in the WPF/Windows app to set the drop object and selection text. The selection text is would be the unique identifier and can be a GUID.