This seems like it should be an easy thing, but it's not working the way I expect it to. I have a SharePoint 2010 site with a document library that contains several Word documents. Office web apps are installed, and the default setting for the farm is to open Word documents in the browser.

When I click on a document link in the AllItems.aspx list view, it does open in the browser (as desired). However, if I click on the same document in a CQWP on a different page, it always prompts me to download the document. How can I force the CQWP to open Word documents in the browser?


3 Answers 3


Apparently this is a known issue.

I've got two possible solutions for you.

1) Enable the "Open documents in client applications by default" site collection feature (from MSDN):


2) Modify the XSL to open the document in a new browser window (from the SharePoint Developer Team blog):


  • Nice links, I had not come across those. Unfortunately, it seems that both of these suggestions still result in the document opening up in the Office client application. We have some workstations that need to view the documents, but do not have the Office client applications installed.
    – JasonV
    Commented Oct 31, 2012 at 15:35
  • So, the other thing to try here is to use the XSL to alter the link to the document. If you look at the URL in the CQWP as opposed to the URL from the list you will notice they are different. If you can recreate the same URL from the list in the CQWP then it should open the document in the browser. Commented Oct 31, 2012 at 16:16
  • That is actually exactly what I ended up doing. The URL is a little hairy looking, but it seems to work (at least for Word documents, which was my requirement).
    – JasonV
    Commented Nov 2, 2012 at 18:37

For those wondering exactly what I did, I had to edit the ItemStyle.xsl file in the Style Library of my site. In the xsl template for this particular instance of the CQWP, I created a variable called $SiteUrl (I'm not entirely sure I needed to do this, as I am relatively new to this stuff):

<xsl:variable name="SiteUrl">
  <xsl:value-of select="substring-before($SafeLinkUrl,'/Lists/')"/>

Then I leveraged that variable inside of the anchor tag like so:

<div style="position:relative; float:left; padding-right:10px;">
  <a onfocus="OnLink(this)" href="{$SafeLinkUrl}" onmousedown="return VerifyHref(this,event,'1','SharePoint.OpenDocuments','1{$SiteUrl}/_layouts/WordViewer.aspx?id={$SafeLinkUrl}')" onclick="return DispEx(this,event,'TRUE','FALSE','FALSE','SharePoint.OpenDocuments.3','1','SharePoint.OpenDocuments','','1{$SiteUrl}/_layouts/WordViewer.aspx?id={$SafeLinkUrl}','','1','0','0','0x7fffffffffffffff','','')" target="{$LinkTarget}" title="{@LinkToolTip}" class="CQWPHeader" >
    <xsl:if test="$ItemsHaveStreams = 'True'">
      <xsl:attribute name="onclick">
        <xsl:value-of select="@OnClickForWebRendering"/>
    <xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
      <xsl:attribute name="onclick">
        <xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
    <xsl:value-of select="$DisplayTitle"/>

This did the trick for me. If necessary, I suppose I could have used an to look at the file extension and open the Excel viewer for .xls/x files, but that wasn't required for my project.


I found that the Search Results Web Part has an "Open in Browser" option and works. I abandoned both the CQWP and CSWP for this.

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.