Have you explored creating an RTF file in lieu of a Word document?  It's
much less resource intensive and won't crash the server like spawning
winword.exe can.

Just a thought.

Dave


----- Original Message -----
From: "Douglas Jordon" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Tuesday, January 22, 2002 1:30 PM
Subject: Word Com Problems


Hi,

 I'm trying to generate an events calendar in Word via CF. I've tried
two solutions, both of which have problems:

 1. The first used <CFTRY> <CFCATCH> etc from cfcomet.com to test for a
Word instance and then launch a new if necessary. The code works, but
the problem with this one is that the winword.exes accumulate and can't
be shut down except by rebooting("Debug" is grayed out). It seems that
every third or fourth call would start a new winword.exe.

 2. Writing a Server variable. The code is from Ben Forta's Advanced CF
Development. It successfully runs the first time and shuts down the
process, but any subsequent attempts get this:

 Error building an argument list for: VISIBLE

 COM error 0x8001010E. The application called an interface that was
marshalled for a different thread.

I tried changing the scope to session variables with the same result:
one success then failure.

 Any ideas? Code below

 Thanks,

 Doug Jordon

Solution 1:

        <!--- Try to connect to the Word application object --->
          <CFTRY>
                     <!--- If it exists, connect to it --->
              <CFOBJECT
                         ACTION="CONNECT"
                         CLASS="Word.Application"
                         NAME="objWord"
                         TYPE="COM">
                   <CFCATCH>
                <!---  The object doesn't exist, so create it --->
                     <CFOBJECT
                         ACTION="CREATE"
                         CLASS="Word.Application"
                         NAME="objWord"
                         TYPE="COM">
                   </CFCATCH>
                 </CFTRY>

Solution 2:

 <!--- See if the Server object exists --->
 <cfif not isdefined("Server.objWord")>
   <!--- Create the object --->

  <CFOBJECT
                         ACTION="CREATE"
                         CLASS="Word.Application"
                         NAME="objWord"
                         TYPE="COM">
       <!--- Exclusive lock in the Server scope --->
   <cflock
       type="Exclusive"
       scope="SERVER"
       timeout="10"
       throwontimeout="Yes">

       <!--- Pass the COM reference to the Server scope --->

 <cfset Server.objWord = objWord>
   </cflock>
   </cfif>
          <!--- Read-only lock in the Server scope --->
  <cflock type="READONLY"
   scope="SERVER"
   timeout="10"
   throwontimeout="Yes">
   <!--- pointer to the original Server variable --->
 <cfset objWord = Server.objWord>
   </cflock>

______________________________________________________________________
Why Share?
  Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to