I have a web site with MSword documents. When I click on the links, it opens the document from inside the web browser. I was wondering how to do so that when you click the link it opens microsoft word. (Like when you have a link to a .wpt file, it opens corel wordPerfect.)
Thanks

Dani AI

Generated

Short answer: IE will display Word documents inside the browser when Windows/IE let Word host the file inline. To force Word to open in its own application you can either change the client file-type behavior on each PC or make the web server send the file as a download (Content-Disposition: attachment). Both approaches work for the Windows + IE6 setup you described.

Client-side (single machine / small controlled environment)

  • In Windows Explorer choose Tools → Folder Options → File Types.
  • Find the DOC extension, click Advanced (or Edit), and disable “Browse in same window” (or uncheck “Open in same window”).
  • After that, clicking a .doc link causes Word to open in its own window instead of embedded in IE.

Server-side (best when you can’t change every client)

  • Serve the document with a Content-Disposition header set to attachment; this tells browsers to download and hand the file to Word instead of embedding it.
  • Example (PHP):
    header('Content-Type: application/msword');
    header('Content-Disposition: attachment; filename="document.doc"');
    readfile($filePath);
    exit;
  • Example (ASP.NET C#):
    Response.Clear();
    Response.ContentType = "application/msword";
    Response.AddHeader("Content-Disposition","attachment; filename=document.doc");
    Response.WriteFile(filePath);
    Response.End();

Notes and troubleshooting

  • If your .wpt links behave differently, that’s likely because their file association is set to open externally. Changing the DOC association or using the server header will make behavior consistent.
  • Avoid trying to instantiate Word in the browser with ActiveX for this — it’s brittle, browser-specific and a security risk (see ’s point).
  • If users still see inline viewing, check proxy/IIS settings or any front-end that might rewrite headers; also test right-click → “Save Target As” to confirm what the server sends.

As suggested, client file-type changes are simple when you control machines; when you don’t, the Content-Disposition approach is the reliable, cross-client fix.

Recommended Answers

All 3 Replies

Hello,

I do not have an answer for your question, but I do have some things that you might wish to think about.

1) Are all of your viewers going to be MS-Word people, with Windows? Perhaps your website is a closed internal one... where you can plan for your audience. IF that is the case, fine. If not, then you might want to go one step further, and program in the various options available, so that if my Linux box with Open Office reaches your pages, it will work for me too.

2) What about browsers? Will your solution also cover something besides IE?

I am guessing you are looking to open Office within a Windows environment with IE. I believe if this is the case, you might be able to change the file type definitions inside of Windows to force it to open MS-WORD.

Christian

Thanks for the reply. Everyone will be using Windows with IE6.0, that's not a problem. My .wpt files work exactly like I want but it does not do the same with my .doc files.

I have a web site with MSword documents. When I click on the links, it opens the document from inside the web browser. I was wondering how to do so that when you click the link it opens microsoft word. (Like when you have a link to a .wpt file, it opens corel wordPerfect.)
Thanks

I'd suggest trying out the .net/vb etc. forums. They will probably be able to help. I would believe it would require an activeX object, or something of the sort. :confused:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.