8

Microsoft Office registers several protocol handlers such as ms-word, ms-excel, etc. Limited documentation is available here. I am attempting to use the Excel protocol handler to open a document passing it a file uri and not having much luck. I can make the operation work with an http/https uri without issue, however in my case the document resides on a network file share.

This works if the document is on a web server:
ms-excel:ofv|u|http://someserver/somefolder/document.xlsx

This does not work:
ms-excel:ofv|u|file://someserver/somefolder/document.xlsx

I receive the following error:

The action couldn't be performed because Office doesn't recognize the command it was given.

Is there any way to make these protocol handlers work with a file URI?

ashleedawg
  • 20,365
  • 9
  • 72
  • 105
codechurn
  • 3,870
  • 4
  • 45
  • 65
  • Where did that file URI come from? It does not look correct to me. UrlCreateFromPath converts \\someserver\somefolder\document.xlsx to file://someserver/somefolder/document.xlsx – Anders Mar 21 '17 at 18:00
  • @Anders The file uri I had in the originally had extra slashes. I have updated the question to remove them. – codechurn Mar 22 '17 at 02:39
  • And how are you executing? ShellExecute? Clicking a link in a browser? SharePoint? – Anders Mar 22 '17 at 02:56
  • As a test, I have built a simple html page with an anchor tag where the href is equal to `ms-excel:ofv|u|file://someserver/somefolder/document.xlsx` . The page is hosted via IIS and I hit it via my browser and attempt to click the link. – codechurn Mar 22 '17 at 03:34

3 Answers3

0

As mentioned here it could be issue of access rights. Have you tried to access the file via File Explorer?

In my case, I could not open the file until I first accessed the folder manually. File Explorer required me to enter credentials. After I entered them and retried the link, it worked.

chriemmy
  • 119
  • 11
0

I've been running into the same problem. Using the Office 2016 or 365 appears to work. 2013 or earlier doesn't.

The way around it is to define your own protocol handler and write a simple program to open the file (start myfile.xlsx). Messy, but I don't think it can be solved any other way without upgrading office.

Cruachan
  • 15,733
  • 5
  • 59
  • 112
-1

try ms-excel:ofv|u|file://(Your IP Address or any address)/somefolder/document.xlsx

yasarui
  • 6,209
  • 8
  • 41
  • 75