[Question] I am speechless when PHP reads the error message from the wordCOM component.

Source: Internet
Author: User
[Question] I am speechless when PHP reads the error message from the wordCOM component.
 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


Reply to discussion (solution)

The first time you start the test in the morning, it is okay. if you change the name of a word, an error will be reported again after the test.

The first instance is not closed.

The first time you start the test in the morning, it is okay. if you change the name of a word, an error will be reported again after the test.

Sorry, I didn't understand it.

The same code.

The first instance is not closed.


Sorry, I didn't understand it.

The same code.

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.

Why is the result of my editing 14 rows incorrect?
Fatal error: Uncaught exception 'com _ exception' with message'Source:Microsoft Word
Description:??? Why? Bytes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.