With relentless off-list help from David Shadovitz, we finally have code (below) to
convert Word documents into HTML! There are a few minor issues/questions embedded in
the code, but it works quite nicely, and it works with Word 2000. Thanks to David and
all others who helped!
Gregory M. Saunders, Ph.D.
Senior Design Architect
Cognitive Arts Corporation (http://www.cognitivearts.com)
120 S. Riverside Plaza, Suite 1520
Chicago, IL 60606
<!---
File: word2HTML.cfm
Comments: This code snippet shows how to convert Word docs into HTML using Word
2000.
Author: Greg Saunders ([EMAIL PROTECTED]),
with much help from David Shadovitz ([EMAIL PROTECTED])
Date: May 15, 2000
Issues:
* The code should open the Word doc as read-only, but it doesn't.
* The value of Word's HTML converter is hard-coded, and may not match the numeric
value
of the converter on your server. See the more detailed comment about this below.
* I don't know if we should CFLOCK the call to CFOBJECT.
--->
<!--- File system variables for testing --->
<cfset dir = getDirectoryFromPath(getBaseTemplatePath())>
<cfset file = dir & "test.doc">
<cfset target = dir & "test.html">
<!--- The class of Word's HTML converter. Note: the numeric value of this converter
may vary
from computer to computer. We should be able to loop through the
"wordApp.fileConverters"
collection to find a fileConverter with fileConverter.className="HTML", and then use
fileConverter.saveFormat, but this did not work, since there was no fileConverter with
className="HTML" found, at least on my machine. For more information, see
http://support.microsoft.com/support/kb/articles/Q224/0/66.ASP --->
<cfset htmlConversionClass = 8>
<!--- Main code. Should this be CFLOCKED? --->
<CFOBJECT ACTION="Create" NAME="WordApp" CLASS="Word.Application">
<cfset WordApp.Visible = FALSE>
<cftry>
<cfset WordDoc = WordApp.Documents>
<!--- We should open the document as READ-ONLY, but I don't know how. The
syntax
should be: expression.Open(FileName, ConfirmConversions, ReadOnly, ...), but
I could
not get it to work, with either val(TRUE) or val(1) for the flags. --->
<cfset success = WordDoc.Open(file)>
<cfset ActiveDoc = WordApp.ActiveDocument>
<cfset success = ActiveDoc.SaveAs(target, val(htmlConversionClass))>
<cfcatch type="ANY">
failed...<cfoutput>#CFCATCH.message#</cfoutput>
</cfcatch>
</cftry>
<cfset success = ActiveDoc.Close()>
<cfset success = WordApp.Quit()>
<cfset WordApp = "">
<!--- Show the results --->
<h1>HTML for sample word doc</h1>
<textArea cols="80" rows="15"><cfinclude template="test.html"></textarea>
<p><cfinclude template="test.html">
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.