Ik heb momenteel de volgende code:
<?php
echo "<p>Word Test Loaded: ".date("d-m-Y H:i:s")."</p>";
$filename = $_SERVER['DOCUMENT_ROOT']."/tmp/test.doc";
if(file_exists($filename)){
echo "<p>The file $filename exists</p>";
$word = new COM("word.application") or die ("<p>Could not initialise MS Word object.</p>");
print "<p>Loaded Word, version {$word->Version}</p>";
$word->Visible = true;
$word->Documents->Add();
$word->ActiveDocument->Open($filename);
print "<p>Document opened</p>";
$word->ActiveDocument->SaveAs("test",8);
print "<p>Document saved</p>";
$word->Quit();
$word->Release();
$word = NULL;
echo "<p>Word Closed</p>";
} else {
echo "<p>The file $filename does not exist</p>";
}
?>
Maar ik krijg onderstaande foutmelding:
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft Word<br/><b>Description:</b> Deze opdracht is niet beschikbaar omdat er geen document is geopend.' in C:\inetpub\wwwroot\word2html\index.php:17 Stack trace: #0 C:\inetpub\wwwroot\word2html\index.php(17): unknown() #1 {main} thrown in C:\inetpub\wwwroot\word2html\index.php on line 17
Ik heb Windows Server 2008 Standard, en ik heb Microsoft Office 2007 erop geïnstalleerd.
Het bestand bestaat:
The file C:\inetpub\wwwroot/tmp/test.doc exists
En MS Word wordt ook gevonden:
Loaded Word, version 12.0
2.375 views