I have a bunch of documents that are either word or excel files generated by a third party program. They are all saved with an XML file extension. When opening the file from File explorer, office xml handler determines which office prg to open them with and does so. I have uploaded all these XML files to a Sharepoint library. When click on the name of the file in the library they open in the appropriate program. I next created a list based on an excel index file that is provided. In this list I created a link to the file in the sharepoint file when there is an appropriate list entry. The problem is when using the link, the xml file is opened up in the web browser and is all the "Raw" formatting of the xml file.

I did some research and found the opposite problem where people were trying to force the links to open in OWA (assuming that is Office Web Application) in the browser instead of downloading the file. The apparent solution to that problem was to add ?web=1 at the end of the link.

I followed this link to a similar Q on stack, and I also followed a subsequent link to deal with exceptions but it was for C# and powershell, and I was not totally following.

SharePoint 2010: Open .webpart file in Web Part Gallery in browser like .xml file

Is there a way to modify the link that will force the file to either be opened via the appropriate office program or conversly downloaded so the file can be opened locally by the appropriate app? Opening would be prefered over downloading, but I am open to both.

This is what I am getting when I follow my current links:

example 1

What I should be getting (MS Word in this case): Example 2

The current link format I am using is:



Found this solution for forms where they modified the link for infopath for a form they were using. I am not understanding all the changing in the accepted answer. Wondering if similar change could be made for word and excel files saved in xml format.

Open instead of prompt for download XML Documents on IE (Link emailed from a SPD WF)


I tried adapting the link to:


But that just threw an error on the sharepoint page. I am assuming this I because it is not a form. I then tried the following:


This resulted in nothing happening. I am assuming that is because the guest key is missing and I don't know what it is. I then tried the following:


Which seems to work in forcing a prompt for open, save/save as and Cancel. When open is clicked, the file is opened in the correct desktop prg. Is there a way to modify the url so that Open is automatically accepted instead?

1 Answer 1


Office supports URI schemes, which means that the following link will open directly in word:


The problem with the above is that SharePoint doesn't work with these URLs. They are not accepted in hyperlink fields, nor are they accepted as links in a multi-line text field with the full formatting option. (this latter option lets you put the link in, but SP strips out the link when you save the item).

So perhaps get a developer to write a custom web part to use these URLs, or add a content editor web part to the allitems.aspx page with the following entered into the source:

<script type="text/javascript">
      var varXMLLink = $(".xmllink").attr("href");
      $(".xmllink").attr("href", "ms-word:ofe|u|" + _spPageContextInfo.siteAbsoluteUrl + varXMLLink);

In addition, use a multi-line text field that has the url entered into source mode like the following:

<a href='/Shared%20Documents/testxml.xml' class='xmllink'>testxml.xml</a>

So, the list has a field with html that has a relative url to the xml file, and that link has a class of 'xmllink'. The javascript waits for the page to load, finds all elements with a class of 'xmllink', and adds the Office URI scheme and the site url to the href.

The js above requires jquery, which might be added to the page already, or a reference would have to be added. (in a pinch, jquery could be uploaded to a library on the site, and a reference could be added in the content editor web part code, prior to the custom script).

  • I currently do not have the ability to test this out. However if I am reading this right, it is forcing all xml documents to open in word? I am asking as some of my xml documents are excel files.
    – Forward Ed
    Commented Sep 26, 2019 at 20:02
  • See the URI schemes link, but office supports this mechanism for word, excel, access, powerpoint, and others. For excel, it would be ms-excel instead of ms-word. That does mean the script would need to check the file extension to determine which prefix to attach to the url.
    – Mike2500
    Commented Sep 26, 2019 at 20:04
  • That is the thing, all the extensions are the same, XML. Within the second line of the document, the xml code specifies the associated document to open with. can the Allitems.Aspx open the file, read the second line, then pick the appropriate URI scheme to use?
    – Forward Ed
    Commented Sep 26, 2019 at 20:12
  • Oh, sorry, wasn't thinking. If you're manually adding the link to another list, you could add an additional field to indicate the type, or append a query string to the url: myfile1.xml?type=xlsx. The script could read that field or querystring value and use that to determine what url to generate.
    – Mike2500
    Commented Sep 26, 2019 at 20:15
  • Problem is the file are generated by third party and I do not know what file format they are until I actually open them. I developed some code to batch upload the files into a share point library then another chunk of code to generate a corresponding list that has a few extra entries. When an entry has a corresponding file I insert the link, and when there is no corresponding file I leave the link field blank.
    – Forward Ed
    Commented Sep 26, 2019 at 20:23

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.