We are going to implement Office Online Server to allow users to view documents in the browser. They should not see any of the buttons like "Share", or "Embed". E.g. for sharing, this results in an error, as we have disabled Sharing on the document library level. However, the button is still visible...

I've tried to add custom JS/CSS, but as far as I can tell this is not possible. The actual ASPX page is a layouts page, and as far as I can see, it does not use a master page. So I can't add CSS/JS. I haven't tested adding CustomActions but I don't think that will work?

So question is: How can I hide the buttons in Office Online Server for SP2016 On Premises?

  • could you add a screenshot of which share, embed button you are talking about? Commented Jan 16, 2017 at 8:35

4 Answers 4


It's not supported OOTB in Office web apps server.

So you can try the below method. Please note that this method is absolutely not recommended and would most likely be overwritten in a future SharePoint CU update.

Here you go:

For hiding the Share and Embed button in Word,Excel and Powerpoint file, you need to modify the WordViewer.css , excelframe.css , stylesread.css files respectively.

In the 2010, environment, we found the wordviewer.css file at below path and can be edited:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\INC\1033\WordViewer\WordViewer.css

So, this path might change in the 2016 environment. Just press F12 and check the file path of the above files. Edit the css file, add below css. The selectors(id of the elements) could be different in your environment.

Please take a backup of the files before editing.

//hiding share button in word

//hiding share button in excel

//hiding share button in powerpoint

You can find the selector of embed button by inspecting the element and adding display none to it as well.

Once you change the css , save it do an IISRESET. Check the file in browser now.

  • Thanks very much for your reply. We won't be able to edit files in the 16 hive as per client's requirement, obvious reason that as you say these may be overwritten in an update. Another solution would be to create an HTTPHandler that injects CSS if one of these files is requested, but again that's not future proof :(
    – Boland
    Commented Jan 16, 2017 at 7:50

Boland, these buttons should have unique div IDs, so you should be able to reference them in the default master page without breaking anything else.

Take a look at this other post:

Hide/disable ribbon bar buttons with client-side code

  • The problem is that this Office Online Server page is not using the default master page as far as I can tell, as per my question.
    – Boland
    Commented Jan 15, 2017 at 23:36
  • You wrote that it doesn't have a custom master page, so which is it?
    – jpollar
    Commented Jan 16, 2017 at 0:39
  • I meant that you can't change the master page, it's a fixed master page.
    – Boland
    Commented Jan 16, 2017 at 0:54
  • You located it and can't open it?
    – jpollar
    Commented Jan 16, 2017 at 0:56
  • There is no master page. Sorry for being so vague, it's Monday here.
    – Boland
    Commented Jan 16, 2017 at 0:59

This is not supported out of the Box as jpollar already mentioned. If you are using some load balancing you might like us (using Netscaler) to rewrite CSS on the fly (without touching the original css) we use this technique to hide some buttons in the BI silverlight webpart.


To hide the toolbars you just have to set the value of the URL variable "action" to "embedview". Ex: https://site/_layouts/15/WopiFrame2.aspx?sourcedoc=...&file=...&action=embedview

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.