OK, I have tested this code on 3 machines, all get the wrong count. Anyone
know what is going on?

Thanks!
Robert Bailey
Famous for nothing


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


hmmm, very odd. Maybe my install of word is messed up here?

So I wrote a quick script in word:

   Sub Test()

   Dim DocOpen As Word.Document

   Set DocOpen = Documents.Open("c:\blah.doc")

   With DocOpen
   MsgBox "The name of this doc is " & .Name & "Which has a count of " &
.Words.Count
   .Close wdDoNotSaveChanges
   End With
   Set DocOpen = Nothing

   End Sub

OK, simple, displays the name of the document and how many words. The
document I opened has one word, simply "hi"

Even this script returns is as 2 words! But if I open up blah.doc in MS Word
manually and check the count, it says one word, as it should. Also, when I
am using the com object, I can not get the .name value, says it is not a
method. Know anything about this at all? is it something I should not worry
about?

Thanks!
Robert Bailey
Famous for nothing


-----Original Message-----
From: Mike Townend [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 11, 2003 2:23 PM
To: CF-Talk
Subject: RE: MS Word Object


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
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

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

Reply via email to