[Question] I am speechless when PHP reads the error message of the wordCOM component !!!! PHPcode & lt ;? Php creates an index pointing to the new COM component $ wordnewCOM (& quot; word. application & quot;) ordie (& quot; CantstartWord! & Quot;); open a document $ w [question] PHP to read the error message of the word COM component. I am speechless !!!!
PHP code
Documents-> OPen ("F:/wamp/www/oa/111.doc"); // read the document content $ test = $ word-> ActiveDocument-> content-> Text; echo $ test; echo"
"; // Replace $ test = str_replace (" <{variable}> "," This is a variable ", $ test); echo $ test; $ word-> Documents-> Add (); // Add the text in the new document $ word-> Selection-> TypeText ("$ test "); // save the document in the directory $ word-> Documents [1]-> SaveAs ("F: \ wamp \ www \ oa \ 111.doc "); // close the connection to the COM component $ word-> Quit ();?>
Error reports in IE browser
Fatal error: Uncaught exception 'com _ exception' with message 'failed' to create com object 'word. application': CoInitialize has not been called. 'In F: \ wamp \ www \ oa \ newfile. php: 3 Stack trace: #0 F: \ wamp \ www \ oa \ newfile. php (3): com-> com ('Word. applicatio... ') #1 {main} thrown in F: \ wamp \ www \ oa \ newfile. php on line 3
Travel error reports
Fatal error: Uncaught exception 'com _ exception' with message 'failed' to create com object 'word. application': CoInitialize has not been called. 'In F: \ wamp \ www \ oa \ newfile. php: 3 Stack trace: #0 F: \ wamp \ www \ oa \ newfile. php (3): com-> com ('Word. applicatio... ') #1 {main} thrown in F: \ wamp \ www \ oa \ newfile. php on line 3
I beg for an explanation
------ Solution --------------------
The first instance is not closed.
------ Solution --------------------
The third line is wrong. Or a fatal error. "F:/wamp/www/oa/111.doc and F: \ wamp \ www \ oa \ 111.doc do you have a problem with this path? Check carefully.