tecdesign Posted April 8, 2007 Share Posted April 8, 2007 I need to count the number of words in a microsoft word document. I have search the internet and so far no good. Anyone have any ideas? Link to comment https://forums.phpfreaks.com/topic/46092-read-a-word-document/ Share on other sites More sharing options...
tecdesign Posted April 8, 2007 Author Share Posted April 8, 2007 This is suppose to be a way $word = new COM("word.application") or die("Unable to instantiate Word"); $word->Documents->Open($filename); $new_filename = substr($filename,0,-4) . ".txt"; // the '2' parameter specifies saving in txt format $word->Documents[1]->SaveAs($new_filename,2); $word->Documents[1]->Close(false); $word->Quit(); $word->Release(); $word = NULL; unset($word); $fh = fopen($new_filename, 'r'); // this is where we exit Hell $contents = fread($fh, filesize($new_filename)); fclose($fh); unlink($new_filename); But I keep getting the error Cannot instantiate non-existent class: com in public_html/editor/word_count.php on line 28 Anyone know how to use the above code. Link to comment https://forums.phpfreaks.com/topic/46092-read-a-word-document/#findComment-223977 Share on other sites More sharing options...
tecdesign Posted April 8, 2007 Author Share Posted April 8, 2007 Ok after reading the COM section on php.net. You need to run php on a windows server for the COM classes to work. Link to comment https://forums.phpfreaks.com/topic/46092-read-a-word-document/#findComment-224320 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.