Jump to content

read a word document


tecdesign

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.