mtoynbee Posted November 21, 2008 Share Posted November 21, 2008 I am trying to start learning PHP COM and have the following script: <?php error_reporting(E_ALL); try { $filename = "brief_synopsis.doc"; $word = new COM("word.application") or die("Unable to instantiate Word"); $word->Documents->Open($filename); $new_filename = substr($filename,0,-4) . ".txt"; $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'); $contents = fread($fh, filesize($new_filename)); fclose($fh); unlink($new_filename); } catch (com_exception $e) { $err = array('errorCode' => $e->getCode(), 'errorMessage' => $e->getMessage(), 'errorFile' => $e->getFile(), 'errorLine' => $e->getLine()); var_dump($err); } ?> I get the exception error dump as: array(4) { ["errorCode"]=> int(-2147221020) ["errorMessage"]=> string(64) "Failed to create COM object `word.application': Invalid syntax " ["errorFile"]=> string(46) "E:\Inetpub\wwwroot\Intranet\phpcom.php" ["errorLine"]=> int(6) } I am using Windows Server 2003. IIS, PHP 5 Any ideas what is causing the error? Or if anyone has a working script for opening and view an MS Word file let me know. Thanks. Link to comment https://forums.phpfreaks.com/topic/133639-php-com-error/ Share on other sites More sharing options...
mtoynbee Posted November 24, 2008 Author Share Posted November 24, 2008 *bump* Link to comment https://forums.phpfreaks.com/topic/133639-php-com-error/#findComment-697673 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.