Skip navigation
Currently Being Moderated

How can I get an RTF file to open properly in MS Word?

Mar 26, 2013 4:00 PM

I'm using Coldfusion 8 and trying get it to export to Microsoft Word an RTF file  that was also created in Word, and is stored on the server. The problem is that when Word opens from the browser, it displays the RTF code for the document as if I'd opened the file in a text editor. The extension is ".rtf", and I've tried using ".doc" and ".docx" but nothing works. And even though Word opens it with an rtf extension, if I do a "Save As", it wants to save the file as an .htm file. I've also tried changing the content-type to "application/msword" but this didn't work. Also if I use OpenOffice instead of MS Word it still doesn't work. My code is below, if anyone could tell me what I'm doing wrong it would be very appreciated.



<cfset formFile = "test.rtf">


<cfset pathToRTF =  GetDirectoryFromPath(GetCurrentTemplatePath()) & formFile />



    <!---<cfset rtfForm = FileRead(pathToRTF) />--->







<cfcontent type="application/rtf">

<cfheader name="Content-Type" value="application/rtf">

<CFHEADER NAME="Content-Disposition" VALUE="filename=test.rtf">





More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points