Page 1 of 1

convert doc to text

Posted: Mon May 17, 2010 1:23 am
by roopa
hi i i have written the code doc to text but error is display

<?php
$filename="cv.doc";
$TXTfilename = $filename . ".txt";
$word = new COM("word.application") or die("Unable to instantiate Word object");
$word->Documents->Open($filename);
$word->Documents[1]->SaveAs($TXTfilename ,2);
$word->Documents[1]->Close(false);
$word->Quit();
$word->Release();
$word = NULL;
unset($word);
$content = file_get_contents($TXTfilename);
unlink($TXTfilename);
?>



Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft Word<br/><b>Description:</b> This file could not be found. (C:\WINDOWS\system32\cv.doc)' in C:\wamp\www\readword _doc\sample_new\sample1.php:5 Stack trace: #0 C:\wamp\www\readword _doc\sample_new\sample1.php(5): variant->Open('cv.doc') #1 {main} thrown in C:\wamp\www\readword _doc\sample_new\sample1.php on line 5

Re: convert doc to text

Posted: Mon May 17, 2010 1:37 am
by cpetercarter
I guess that line 5 of your code needs the path to the file you want to open, not just the file name. Or perhaps the COM class has a method which sets the directory where documents are located, which you need to call before trying to open a document.

Re: convert doc to text

Posted: Mon May 17, 2010 9:26 am
by mikosiko
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft Word<br/><b>Description:</b> This file could not be found. (C:\WINDOWS\system32\cv.doc)'

message seems very clear to me.... as cpetercarter said... define the path where the file is located