note 35580 added to ref.com
| From: | php at dictim dot com | Date: | Sat, 06 Sep 2003 17:17:37 +0000 |
| Subject: | note 35580 added to ref.com | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-55552@lists.php.net to get a copy of this message | ||
This took me days to work out how to do so I gotta share it:
How to get the word count from a MS Word Document:
#Instantiate the Word component.
$word = new COM("word.application") or die("Unable to instantiate Word");
$word->Visible = 1;
$word->Documents->Open("c:/anydocument.doc");
$temp = $word->Dialogs->Item(228);
$temp->Execute();
$numwords = $temp->Words();
echo $numwords;
$word->Quit();
Note that this is the only way to get the word count accurately:
$word->ActiveDocument->Words->Count;
Will see all carriage returns and punctuation as words so is wildy innaccurate.
----
Manual Page -- http://www.php.net/manual/en/ref.com.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35580
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35580&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35580&report=yes