I have this php code to load a word document : sample.docx
//define a variable
define('wdPropertyTitle', 1);
//instantiate the object OK
$word = new COM("word.application") or die ("Could not initialise MS Word object.");
// check Class
print_r(get_class($word)); // OK dispalys Class_name COM
// load a document
//$word->Documents->Open(realpath("Sample.docx"));
$word->Documents->Open("sample.docx"); // No Exception up to here
//check the object
echo "<pre>";
print_r($word); // respose: object ( )
echo "</pre>";
// get properties
$Print = $word->ActiveDocument->BuiltInDocumentProperties(wdFieldPrint);
?>
Question: When I run the script, I get the following exception:
PHP Fatal error: Uncaught com_exception: <b>Source:</b> Microsoft Word<br/><b>Description:</b> This command is not available because no document is open. in C:\phpFolder\php_codes\class_COM.php:75
Stack trace: #0 {main} thrown in C:\phpFolder\php_codes\class_COM.php on line 75
Do you have any solution to get this thing done?, please
PS: I have : win 10, php 7.4.1, IIS 10 , php_com_dotnet is active in php.ini,
Dcom Configured in windows snap-in
Appreciated
Mohamad Aflatooni