none
Drag and Drop from App for Office 2013 RRS feed

  • Question

  • Hi,

    i am working on Taskpane App for Office ( Word, Powerpoint ) for user to be able to add content into document. Present JS API is not very straightforward to do this programatically, i am only able to replace selected text with some html/ooxml content and only in Word. I understand, that Powerpoint and Word documents can be defined with different structure, and result is that setSelectedDataAsync works with html and ooxml only in Word.

    So I tried to use html5 Drag+Drop, which is unfortunatelly able to drag element in app only. I tried to replace element-data in dragged content with text data through (event:ondragstart).dataTransfer.data("text",str) but it did not work, because as I move mouse out of app territory, cursor changes to something like "cursor:not-allowed" in css and after drop nothing happens. The only destination that worked was recently opened IE11 window.

    App worked as expected when it was opened in IE11 or Firefox as standalone web-page with api disabled, drag+drop worked even with images added to Powerpoint. But why would i use it as standalone app, when there can be api to use it as an sidebar?

    Is there any technique to add text/image from taskpane app to document that works in Word and Powerpoint?

    Thanks, Marek L.

    Tuesday, April 1, 2014 12:28 PM

Answers

  • Hi,

    According to your description, you want to add text or image into document of Word or PowerPoint with task pane app.

    The Document object exposes setSelectedDataAsync method to write data to current selection in the document. But in the picture below(referring to Exploring the New JavaScript API for Office), we can find the PowerPoint can only get and set data as Text and it will not support HTML and OOXML. So we could use the code below to add a text into the selection position. But I’m afraid PowerPoint doesn’t support adding a string with coercionType as html or matrix.

    function writeData() {
        Office.context.document.setSelectedDataAsync("Hello World!",
        function (asyncResult) {
            var error = asyncResult.error;
            if (asyncResult.status === "failed") {
            }
        });
    }

    For inserting image into document with task pane app:

    “The two techniques shown above are currently available only in Word, but you may want your app to also work in Excel or PowerPoint. Unfortunately, not all coercion types are available in the other apps just yet. One option is to display the image inside your app, and instruct the end user to manually copy it into their document” (it had been discussed in blog Inserting images with apps for Office).

    If you have any suggestions about App for Office development, please feel free to submit in User Voice.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 2, 2014 8:21 AM
    Moderator
  • Hi,

    >>Is there any chance, that html5 drag-n-drop will be enabled for content managing with Apps For Office 2013<<

    As far as I know, Apps for Office cannot support using drag and drop to insert text or picture into document currently.

    If you have any suggestions about App for Office development, please feel free to submit in User Voice.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 2, 2014 9:51 AM
    Moderator

All replies

  • Hi,

    According to your description, you want to add text or image into document of Word or PowerPoint with task pane app.

    The Document object exposes setSelectedDataAsync method to write data to current selection in the document. But in the picture below(referring to Exploring the New JavaScript API for Office), we can find the PowerPoint can only get and set data as Text and it will not support HTML and OOXML. So we could use the code below to add a text into the selection position. But I’m afraid PowerPoint doesn’t support adding a string with coercionType as html or matrix.

    function writeData() {
        Office.context.document.setSelectedDataAsync("Hello World!",
        function (asyncResult) {
            var error = asyncResult.error;
            if (asyncResult.status === "failed") {
            }
        });
    }

    For inserting image into document with task pane app:

    “The two techniques shown above are currently available only in Word, but you may want your app to also work in Excel or PowerPoint. Unfortunately, not all coercion types are available in the other apps just yet. One option is to display the image inside your app, and instruct the end user to manually copy it into their document” (it had been discussed in blog Inserting images with apps for Office).

    If you have any suggestions about App for Office development, please feel free to submit in User Voice.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 2, 2014 8:21 AM
    Moderator
  • Thank you for fast reply.

    I have another question. Is there any chance, that html5 drag-n-drop will be enabled for content managing with Apps For Office 2013? Drag-n-drop is enabled when dragging from IE or other browser to Word/PP but not when dragging from App For Office...

    Wednesday, April 2, 2014 8:51 AM
  • Hi,

    >>Is there any chance, that html5 drag-n-drop will be enabled for content managing with Apps For Office 2013<<

    As far as I know, Apps for Office cannot support using drag and drop to insert text or picture into document currently.

    If you have any suggestions about App for Office development, please feel free to submit in User Voice.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 2, 2014 9:51 AM
    Moderator