locked
[JavaScript API] How to get elements info from a PowerPoint slide RRS feed

  • Question

  • Hi everyone,

    I'm playing with the new JavaScript Office API, which I think is awesome news. I've been playing with the Excel API and no many problems so far. The thing is that I have one objective with the PowerPoint API that I couldn't reach yet: How to extract all the info from a slide.

    I used Document.getSelectedDataAsync but I found that only Office.CoercionType.SlideRange can be used for PowerPoint, and it only returns a JSON with id, title and index.

    I'm looking for a way to extract the objects data from an specific slide. This may be done by exporting the file and then accessing to the XML file, mapping it to JSON and sending it to our API so we can consume that data later. This option has a huge development cost (sending the entire file).

    So the final question is as follows: Which is the best method to get a JSON with the data from all the objects placed on a unique slide from PowerPoint?

    Thanks in advance!


    Tuesday, May 6, 2014 9:43 AM

Answers

  • Hi Fernando Agüero,

    >> I'm looking for a way to extract the objects data from a specific slide. Which is the best method to get a JSON with the data from all the objects placed on a unique slide from PowerPoint?

    As far as I know, there are no methods to loop all shape objects from a specific slide in current Office JavaScript API. As you said, there are only id, title and index in the result of Document.getSelectedDataAsync.

    Below is a sample about how to use SlideRange:

    function gotoSelectedSlide() {
        //Get currently selected slide's id
        Office.context.document.getSelectedDataAsync(Office.CoercionType.SlideRange, function (asyncResult) {
            if (asyncResult.status == "failed") {
                showMessage("Action failed with error: " + asyncResult.error.message);
            }
            else {
                var firstSlideId = slideRange.slides[0].id;
                showMessage(JSON.stringify(asyncResult.value));
            }
        });
        //Go to slide by id.
        Office.context.document.goToByIdAsync(firstSlideId, Office.GoToType.Slide, function (asyncResult) {
            if (asyncResult.status == "failed") {
                showMessage("Action failed with error: " + asyncResult.error.message);
            }
            else {
                showMessage("Navigation successful");
            }
        });
    }

    Document.goToByIdAsync method (JavaScript API for Office v1.1)

    Roadmap for Apps for Office, VSTO, and VBA

    If you have any suggestions for Office Development Platform, please feel free to submit them to User Voices.

    Regards,

    Jeffrey


    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, May 7, 2014 9:22 AM

All replies

  • Hi Fernando Agüero,

    >> I'm looking for a way to extract the objects data from a specific slide. Which is the best method to get a JSON with the data from all the objects placed on a unique slide from PowerPoint?

    As far as I know, there are no methods to loop all shape objects from a specific slide in current Office JavaScript API. As you said, there are only id, title and index in the result of Document.getSelectedDataAsync.

    Below is a sample about how to use SlideRange:

    function gotoSelectedSlide() {
        //Get currently selected slide's id
        Office.context.document.getSelectedDataAsync(Office.CoercionType.SlideRange, function (asyncResult) {
            if (asyncResult.status == "failed") {
                showMessage("Action failed with error: " + asyncResult.error.message);
            }
            else {
                var firstSlideId = slideRange.slides[0].id;
                showMessage(JSON.stringify(asyncResult.value));
            }
        });
        //Go to slide by id.
        Office.context.document.goToByIdAsync(firstSlideId, Office.GoToType.Slide, function (asyncResult) {
            if (asyncResult.status == "failed") {
                showMessage("Action failed with error: " + asyncResult.error.message);
            }
            else {
                showMessage("Navigation successful");
            }
        });
    }

    Document.goToByIdAsync method (JavaScript API for Office v1.1)

    Roadmap for Apps for Office, VSTO, and VBA

    If you have any suggestions for Office Development Platform, please feel free to submit them to User Voices.

    Regards,

    Jeffrey


    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, May 7, 2014 9:22 AM
  • Hi Jeffrey,

    Thanks for answering but it doesn't meet the requirements I need to do the job. Anyway, I will post all the suggestions via User Voice.

    Regards,

    Fernando

    Friday, May 16, 2014 2:34 PM