note 35580 modified in ref.com by danbrown

From: Date: Mon, 21 Dec 2009 17:15:11 +0000
Subject: note 35580 modified in ref.com by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-164229@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: <?php #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. --was-- 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. http://php.net/manual/en/ref.com.php

« previous php.notes (#164229) next »