Hi, I am developing an application that will read a Microsoft Word Document and display it as HTML. I am using the following code, which is an example off of livedocs. However, I am getting this error message:
An exception occurred when instantiating a Com object.
The cause of this exception was that: coldfusion.runtime.java.JavaObjectInstantiationException: Object Instantiation Exception..
The error occurred in C:\CFusionMX\ line 30
Called from C:\CFusionMX\ line 30
Called from C:\CFusionMX\ line 30
28 : <cfobject type="com"
29 : action="Create"
30 : class="Word.Application"
31 : name="Application.MyWordobj"
32 : context="local">
Thank you for your help in advance.
Keith
The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents.
An exception occurred when instantiating a Com object.
The cause of this exception was that: coldfusion.runtime.java.JavaObjectInstantiationException: Object Instantiation Exception..
The error occurred in C:\CFusionMX\ line 30
Called from C:\CFusionMX\ line 30
Called from C:\CFusionMX\ line 30
28 : <cfobject type="com"
29 : action="Create"
30 : class="Word.Application"
31 : name="Application.MyWordobj"
32 : context="local">
Code:
<cfapplication name="comtest" clientmanagement="No" Sessionmanagement="yes">
<!--- Uncomment the following line if you need to delete the object from the
Application scope --->
<!--- <cfset structdelete(Application, "MyWordObj")> --->
<!--- use the GetTickCount function to get a current time indicator, used for
displaying the total processing time. --->
<cfset start = GetTickCount()>
<!--- If necessary, create the Word.application object and put it in the
Application scope --->
<cfset WordObj_is_initialized = False>
<cflock scope="application" type="readonly" timeout=120>
<cfset WordObj_is_initialized = StructKeyExists(application, "MyWordObj")>
</cflock>
<cfif not WordObj_is_initialized >
<cflock scope="Application" type="exclusive" timeout="120">
<cfif not StructKeyExists(application, "MyWordObj")>
<!--- First try to connect to an existing Word object --->
<cftry>
<cfobject type="com"
action="connect"
class="Word.Application"
name="Application.MyWordobj"
context="local">
<cfcatch>
<!--- There is no existing object, create one --->
<cfobject type="com"
action="Create"
class="Word.Application"
name="Application.MyWordobj"
context="local">
</cfcatch>
</cftry>
<cfset Application.mywordobj.visible = False>
</cfif>
</cflock>
</cfif>
<!--- Convert a Word document in temp.doc to an HTML file in temp.htm. --->
<!--- Because this example uses a fixed filename, multiple pages might try
to use the file simultaneously. The lock ensures that all actions from
reading the input file through closing the output file are a single "atomic"
operation, and the next page cannot access the file until the current page
completes all processing.
Use a named lock instead of the Application scope lock to reduce lock contention. --->
<cflock name="WordObjLock" type="exclusive" timeout="120">
<cfset docs = application.mywordobj.documents()>
<cfset docs.open("C:\Documents and Settings\N537252\Desktop\test.doc")>
<cfset converteddoc = application.mywordobj.activedocument>
<!--- Val(8) works with Word 2000. Use Val(10) for Word 97 --->
<cfset converteddoc.saveas("C:\Documents and Settings\N537252\Desktop\temp.htm",val(8))>
<cfset converteddoc.close()>
</cflock>
<cfoutput>
Conversion of temp.htm Complete<br>
Execution Time: #int(getTickCount()-start)# milliseconds<br>
</cfoutput>
Thank you for your help in advance.
Keith
The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents.