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
convert doc to text
Moderator: General Moderators
-
cpetercarter
- Forum Contributor
- Posts: 474
- Joined: Sat Jul 25, 2009 2:00 am
Re: convert doc to text
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
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
message seems very clear to me.... as cpetercarter said... define the path where the file is located