none
Examples of using Javascript to access and opened selected Word or Excel files RRS feed

  • Question

  • I have been trying to find examples of using code like JavaScript of accessing and opening a selected Word or Excel file stored on a person's Office 365 SharePoint or OneDrive.  What I am trying to get around is the lack of events like Open, Close, save, Saveas and other events found on the Office client apps. I am trying to see if I can use the OnLoad event to perform some things in that event that I would do if there was an Open, Close, Save, SaveAS and such events for the Web versions of Excel and Word.

    Thanks

    Jim

    Tuesday, February 23, 2016 4:03 PM

Answers

All replies

  • Hi Jim,

    We can’t perform somethings like client API/object model by using the JavaScript to do with word or excel.

    You need to use REST API (not for word) or JavaScript API for Office (office add-ins).

    More information, please refer to:

    # Excel Services REST API

    https://msdn.microsoft.com/en-us/library/office/ee556413.aspx

    # JavaScript API for Office

    https://msdn.microsoft.com/en-us/library/office/fp142185.aspx

    Regards

    Starain


    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, February 24, 2016 7:17 AM
    Moderator
  • Thank you Starain for the web sites.

    So does the JavaScript API for Office apply to the Web version of Apps (Word, Excel, PowerPoint) and for the web version of those apps?

    https://msdn.microsoft.com/en-us/library/office/fp142185.aspx

    On that page it mentions

    The JavaScript API for Office includes objects, methods, properties, events, and enumerations that you can use in your Office Add-ins code.

    The Microsoft.Office.WebExtension namespace (which by default is referenced using the alias Office in code) contains objects you can use to write script that interacts with content in Office documents, worksheets, presentations, mail items, and projects from your Office Add-ins.

    I assume there is documentation that describes using this API and are there examples? What are the links to that information?

    Wednesday, February 24, 2016 9:57 PM
  • Hi JimBassett,

    Yes, please check it here (supported add-in types). There are some samples too.

    Regards

    Starain


    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.

    Thursday, February 25, 2016 2:03 AM
    Moderator
  • Thank you Starain,

       The site at the "please check it here" link is helpful to me! 

    To me it seems the documentation of the APIs for working with the Office web applications is scattered across different sites. I am sure it is organized but because the Web Office applications development API and such is new to me so I am slowly getting a feel for how to think in this type of development and finding specific documentation that covers areas that I am investigating and/or working on.

    Thank you again Starain!!

    Jim 

    Thursday, February 25, 2016 4:09 AM
  • Hi Jim,

    You may learn it and make the project to test, if you have the issue in the feature, please feel free to open the new threads.

    Regards

    Starain


    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.

    Friday, February 26, 2016 2:12 AM
    Moderator
  • So the JavaScript API for Office (office add-ins) works for Word and Excel or just Word? 

    I would use  Excel Services REST API for Excel and  JavaScript API for Office for Word and the resulting Office add-ins would work with the web version of Word and Excel as well as the client version of those Office applications?

    Thank you,

    Jim

    Friday, March 4, 2016 1:43 PM
  • Hi Jim,

    >>So the JavaScript API for Office (office add-ins) works for Word and Excel or just Word? 

    For word and excel. More information, please refer to the article that I provided.

    The Task pane add-ins type is supported Excel/word client and Online. The REST API is the Http request, so it is used to request the resource online.

    Regards

    Starain


    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.

    Monday, March 7, 2016 1:27 AM
    Moderator
  • Thank you Starain,

    Are there examples of using the API for opening a selected file residing on Office 365 SharePoint folder or library and in a OneDrive folder?  On the the following siite https://msdn.microsoft.com/en-us/library/office/fp142185.aspx I click the Object "File" to look up methods and hopefully examples of using it.  What I found is shown below

    Methods

    Name

    Description

    closeAsync                                           

    Closes the document file.     

    getSliceAsync                                           

    Returns the specified slice.

    The closeAsync method closes the file!! Why isn't there an "Open" method to open the file?` Are there examples of opening and closing a selected Word or Excel file residing on an Office 365 Folder or an OneDrive Folder? 

    Thank you,

    Jim

    Monday, March 7, 2016 5:31 PM
  • Hi Jim,

    Yes, there isn’t the open method to open the file.

    >> Are there examples of opening and closing a selected Word or Excel file residing on an Office 365 Folder or an OneDrive Folder? 

    The JavaScript API for Office doesn’t provide the way to do that.

    You may submit the user voice here.

    Regards

    Starain


    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.

    Tuesday, March 8, 2016 2:36 AM
    Moderator
  • Thank you Starain! You have been so patient with my many questions.

    On this page : https://msdn.microsoft.com/en-us/library/office/jj715284.aspx   there is mention of "Document.getFileAsync method (JavaScript API for Office) " for Office Add-ins   which returns:     

    Returns the entire document file in slices of up to 4194304 bytes (4MB) or for add-ins for iOS up to 65536 (64KB).  This sounds like it is a way to open an entire file.

    Thank you again Starain!!

    Tuesday, March 8, 2016 12:44 PM
  • Hi JimBassett,

    The getFileAsync method is used to get entire current document. A scenario, we could use it to download the file with specify format.

    Regards

    Starain


    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, March 9, 2016 1:46 AM
    Moderator