Skip to main content
Participating Frequently
May 19, 2014
Question

CF 10 cfcontent application/msword displays HTML code instead of document?

  • May 19, 2014
  • 1 reply
  • 310 views

I have this code for a generic template:

   <cfset fileName="c:\temp\wordTmpDoc"&randRange(1,100000)&".htm">

    <cfif fileExists(fileName)><cffile action="delete" file="#fileName#"></cfif>

    <cfsavecontent variable="htm"><CFINCLUDE template="#incl#.cfm"></cfsavecontent>

    <cffile action="write" file="#fileName#" output="#htm#">

    <cfcontent file="#fileName#" deletefile="no" type="application/msword">

Note the CFINCLUDE. I also have another template that goes through generating the html in a cfsavecontent and at the bottom it has essentially the same code but uses the HTML generated on the page as the content for the document. The above generic version brings up MS Word but the content is the HTML code, while the page that has local cfsavecontent wrapping the HTML, the document displays properly.

This topic has been closed for replies.

1 reply

gordon_vaAuthor
Participating Frequently
May 23, 2014

OK, now I'm really confused. I put a cfdump on the generic template, removed it, and moved a closing </div> to the next line on the cfinclude file and now....... it produces a proper Word doc instead of HTML! Ghost in the machine. I did not change anything important one either file, and I lost a LOT of time trying to debug the issue. If anyone else encounters this problem and can explain the cause and the solution, please feel free to contribute.