9

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?

1
  • could you add a screenshot of which share, embed button you are talking about? Jan 16 '17 at 8:35
5
+200

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
#btnFileSharing-Medium20{display:none}; 

//hiding share button in excel
#m_excelWebRenderer_ewaCtl_flyoutExcelShare-Medium20{display:none};

//hiding share button in powerpoint
#PptJewel.Share.ShareWithPeople-Medium20{display:none};

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.

1
  • 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
    Jan 16 '17 at 7:50
0

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

11
  • 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
    Jan 15 '17 at 23:36
  • You wrote that it doesn't have a custom master page, so which is it?
    – jpollar
    Jan 16 '17 at 0:39
  • I meant that you can't change the master page, it's a fixed master page.
    – Boland
    Jan 16 '17 at 0:54
  • You located it and can't open it?
    – jpollar
    Jan 16 '17 at 0:56
  • There is no master page. Sorry for being so vague, it's Monday here.
    – Boland
    Jan 16 '17 at 0:59
0

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.

0

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, privacy policy and cookie policy

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