Try prototyping how to do it in the vba editor (alt-F11) in word, that's how
I always do stuff in word, then you get intellisense and help etc.

Then when you have it done, port it to cfscript and then try running it

HTH



-----Original Message-----
From: Robert Bailey [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 11, 2003 18:49
To: CF-Talk
Subject: MS Word Object


Hey guys.

Playing around here, and trying to count the words in a MS Word document. It
is returning a number, but not the amount of words in the doc, as when I
open it up using word, and look at the count there, it is a few off from
when I use the object. Maybe I am going it wrong.

I created a small document. I open it in the object and do the count (which
I think I am going it right), and the total count is returned as 18. I open
the document in Word, do a count, says I have 14 words. Very odd.

I am using Word 2000 and CFMX. Also, anyone know how I can get the total
pages, document name, paragraphs, etc... that word gives you on the word
count box? not seeing much information on it online, and stumbled up on the
count by mistake, so it may be not what I am trying to do. I just need a
realistic count. The document does have 14 words, as I counted it myself,
not sure why when using the code below it says I have 18 words. Here is the
code. Thanks for any help!

<CFTRY>
   <CFOBJECT
       ACTION="CONNECT"
       CLASS="Word.Application"
       NAME="objWord"
       TYPE="COM">
 <CFCATCH>
   <CFOBJECT
       ACTION="CREATE"
       CLASS="Word.Application"
       NAME="objWord"
       TYPE="COM">
 </CFCATCH>
</CFTRY>

<CFSCRIPT>

   OpenDoc = objWord.Documents.Open("c:\blah.doc");

   Count = opendoc.words.count();

   OpenDoc.Close();

   objWord.Quit();

   objWord = "Nothing";
</CFSCRIPT>
<CFOUTPUT>
COUNT: #count#
</CFOUTPUT>



Thanks!
Robert Bailey
Famous for nothing



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to