Open Office documents in any browser using Office URI scheme

Problem:
One of the problems when shifting to a non-IE browser in SharePoint, is that immediately documents start downloading instead of opening in the browser.
While we can overcome that by tweaking the "Open in browser" library option, sometimes it is just very difficult to interact with Office since we cannot call "CoreInvoke" or functions such as createNewDocumentWithProgIDEx from the SharePoint OpenDocuments Class (OWSSUPP.DLL), often ending up with error message,

The document could not be opened for editing. A Microsoft SharePoint Foundation compatible application could not be found to edit the document.

One possible scenario could be:
How to open an instance of a .dotx Word Document Template in Google Chrome and allow a suggested save location?

Solution:
Starting SharePoint 2013 and Office 2010 SP2, we can use URI schemes, which are basically URLs starting with "ms-X" which trigger the desktop application to open, and works in both IE and Chrome.

Syntax:
ms-[OFFICE_APP]:[OPTION]|u|[URI]|s|[SAVE_LOCATION]

Options:

  • ofv (office file view)
  • ofe (office file edit)
  • nft (new from template)

Office Apps:

  • ms-word
  • ms-powerpoint
  • ms-excel
  • ms-visio
  • ms-access
  • ms-project
  • ms-publisher
  • ms-spd
  • ms-infopath


Examples:

View a document (read-only)
ms-excel:ofv|u|https://contoso/Q4/budget.xls

Edit a document
ms-powerpoint:ofe|u|https://www.fourthcoffee.com/AllHandsDeck.ppt

Create a new instance of a document template
ms-word:nft|u|https://cohowinery/templates/elegance.pot|s|https://cohowinery/presentations

Example of a link in Google Chrome, opening a new document instance from a .dotx template and with a specified save location.
Internet Explorer opens the document immediately, and Chrome prompts for confirmation with an option to suppress it.



References:
Office URI Schemes
Create a link to “New Document” template link

Comments

  1. Fantastic thanks so much for this! Had made several unsuccessful attempts at using JavaScript CoreInvoke methods to open InfoPath filler forms from Chrome, but this is dead simple and works perfectly

    ReplyDelete

Post a Comment

Popular posts from this blog

Mobile development opportunities

Breaking down document locking in SharePoint

Working around X-Frame-Options for iframes