none
Accessing Word or Excel document, Workbook security via Javascript RRS feed

  • Question

  • I have Word and Excel documents in OneDrive or SharePoint and security is applied to them using the build in security features in Excel and Word. I am trying to figure out how to unsecure a Word or Excel file that is opened using Office Web Apps as well as apply security to a Word or Excel file when it is saved or closed using Office Web apps. Looking at the Office API for JavaScript I am not finding the events or methods to use. Maybe security cannot be handled or managed on the Web version of these apps?

    Thank you

    Friday, May 16, 2014 6:11 PM

All replies

  • Hi Jim,

    The APIs for Office Web Apps are not in our scope.

    This forum is used to discuss questions about apps for Office.

    for documents host on OneDrive and SharePoint, we have OneDrive SDK (Rest API) and SharePoint (Rest API) to handle the security part.

    You could get support from corresponding forums:

    OneDrive Development forum

    SharePoint 2013 - Development and Programming forum


    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, May 19, 2014 9:33 AM
    Moderator
  • Thank you George for those other forum links.  I was not clear with my question about Word Document or Excel workbook security. I am not referring to the security permissions of those files on OneDrive or Sharepoint but rather the "Protect Document" type security one can place on the document, Workbook or PowerPoint presentation before they save it such as

    • Encrypt with Password
    • Restrict Editing
    • Restrict Access

    so as to prevent other people making changes to a document, workbook or PowerPoint Presentation. In Office 2013 client you get to it via the Backstage and clicking "Info". Opening a Word, Workbook or PowerPoint Presentation that is protected using the corresponding Office Web App fails due to the protection and so I looking to unprotect them using Office Web App API, Javascript and such.

    I hope that makes clearer my question because I believe the question applies to this forum of "apps for Office"


    • Edited by JimBassett Monday, May 19, 2014 8:37 PM Needed to be clearer
    Monday, May 19, 2014 8:17 PM
  • Hi Jim,

    >> Opening a Word, Workbook or PowerPoint Presentation that is protected using the corresponding Office Web App fails due to the protection and so I looking to unprotect them using Office Web App API, JavaScript and such.

    What do you mean by “fails due to the protection”, are there any error messages or warnings?

    As far as I know, there are no protect and up-protect methods in current Office JavaScript API.

    Roadmap for Apps for Office, VSTO, and VBA

    If you have any feedbacks for current Office Development Platform, please feel free to submit them to User Voice.

    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.


    Tuesday, May 20, 2014 3:00 AM
    Moderator
  • Jeffrey the protection I apply to a Word document or Excel workbook is encryption using a password. When I upload them to OneDrive or to SharePoint and try to open them in the appropriate Office Web app I get the messages:

    For Word - "Sorry Word Online can't open a document that has encryption"

    For Excel - "We're Sorry. We can't open the workbook in the browser because it uses Workbook encryption."

    Note the Word document was saved as docx, and the Excel Workbook as xlsx.

    This is expected behavior but my question is can documents be unprotected using a Office Web App API via Javascript or other web language. I would think the OOXML has sub XML objects containing the encryption and if modified would unprotect the Word Doc and Excel workbook as well as doing the reverse. Is there an method or other Web Office API that can be accessed to do this. Even if there is a method there is a need to capture an Open event or something like an open event of the Word doc or Excel Workbook so as to handle the event and unsecure the contents. The reverse action would be to capture a save or close event of the document or workbook so as to apply protection.

    Also Jeffey what do you mean by "no project" or "up-project" in the sentence below?

    As far as I know, there are no project and up-project methods in current Office JavaScript API.

    Thank you,

    Jim


    Jim


    • Edited by Jim_Fort_Worth Tuesday, May 20, 2014 4:29 AM correct typos
    Tuesday, May 20, 2014 4:26 AM
  • Hi Jim,

    >> But my question is can documents be unprotected using an Office Web App API via Javascript or other web language.

    Currently, we could not open a document that has encryption using Office Web App. And there also no “protect” and “un-protect” methods in current Office JavaScript API (sorry for the misspelling). So I’m afraid we could not achieve this goal via JavaScript. The possible way I could figure is using Office Interop (_Worksheet.Unprotect method).

    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 21, 2014 7:27 AM
    Moderator
  • I use Worksheet.Unprotect and Worksheet.Protect methods now for Client based Excel and the corresponding methods for Word. Seems odd to me that Microsoft would not have these types of methods in the Web API as businesses use this type of protection for their Word, Excel, and PowerPoint files now.  I know people who expect to be able use these documents on the Web version especially if they have Office 365 Small Business and Enterprises license and storing such files on OneDrive and SharePoint. This would allow them to access and work with these documents using a Table like iPad and Android from the tablets browser. Jeffrey is there some email or site to make suggestions to the Office product managers?

    Thanks

    Jim


    Jim

    Thursday, May 22, 2014 1:51 AM
  • Hi Jim,
    >> I know people who expect to be able use these documents on the Web version especially if they have Office 365 Small Business and Enterprises license and storing such files on OneDrive and SharePoint.

    You could consider ways as followings to submit feedbacks for Office:

    1. Office Online (Office Web App): click “HELP IMPROVE OFFICE” at the right-bottom corner.
    2. Office Feedback:  http://office.microsoft.com/suggestions.aspx
    3. Office Development Platform: http://officespdev.uservoice.com

    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.


    Monday, May 26, 2014 3:46 AM
    Moderator
  • Thank you Jeffrey.

    I am aware of being able to use the OOXML SDK to remove or place protection on a document before it is opened or after it is closed. The example node below from the "Settings.xml" file is from a Word document I am testing. 

    <w:documentProtection w:salt="9/iU+rInMwE+qZVLnaFRew==" w:hash="xVnU3MQb1Jo7U6PpeSm//FkSM3VaOMrcG7tURZ3SIFaB5ktn5JveFxzjQS440B98NqW9kR4XurvkmgEOqf4tVA==" w:cryptSpinCount="100000" w:cryptAlgorithmSid="14" w:cryptAlgorithmType="typeAny" w:cryptAlgorithmClass="hash" w:cryptProviderType="rsaAES" w:enforcement="1" w:edit="readOnly"/>

    The issue for me is that the Office Web API or Office Web application engine does not generate events like open, close or something similar where I could either place the above node into the Open XML settings.xml file for protecting or remove it for unprotecting based on opening it, saving it or closing the document on the Office Web. It is of course easy to do on the client since there are events but just not sure how to do it on the Office web if it is even possible.


    Jim

    Tuesday, May 27, 2014 3:47 PM