word2003 English Read and write code for Word documents in PHP

Source: Internet
Author: User
Copy the Code code as follows:


Establish an index to the new COM component
$word = new COM ("Word.Application") or Die ("Can ' t start word!");
Displays the version number of the word that is currently in use
echo "Loading Word, v. {$word->version}
”;
Set its visibility to 0 (false), use 1 (true) if you want to make it open in the front-end
To open the application in the forefront, use 1 (true)
$word->visible = 0;
Hit a document.
$word->documents->open ("D:\myweb\muban.doc");
Read Document Contents
$test = $word->activedocument->content->text;
Echo $test;
echo "
”;
Change the variable you want in your document
$test =str_replace ("<{variable}>", "This is a variable", $test);
Echo $test;
$word->documents->add ();
Add text to a new document
$word->selection->typetext ("$test");
Save the document in the directory
$word->documents[1]->saveas ("D:/myweb/comtest.doc");
To close a connection to a COM component
$word->quit ();
?>

The above describes the word2003 Simplified Chinese version of the code to read and write Word documents in PHP, including the word2003 Simplified Chinese version of the content, I hope to be interested in PHP tutorial friends helpful.

  • 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.