Using COM to open Word
Posted
by chupinette
on Stack Overflow
See other posts from Stack Overflow
or by chupinette
Published on 2010-03-24T16:20:59Z
Indexed on
2010/03/24
16:23 UTC
Read the original article
Hit count: 542
Hello! I am actually trying some codes i found from http://php.net/manual/en/class.com.php
<?php
// starting word
$word = new COM("word.application") or die("Unable to instantiate Word");
echo "Loaded Word, version {$word->Version}\n";
//bring it to front
$word->Visible = 1;
//open an empty document
$word->Documents->Add();
//do some weird stuff
$word->Selection->TypeText("This is a test...");
$word->Documents[1]->SaveAs("Useless test.doc");
//closing word
$word->Quit();
//free the object
$word = null;
?>
But this does not seem to work. I am using Word 2007 and i get the following:
Loaded Word, version 12.0 Fatal error: Call to undefined method variant::SaveAs() in C:\xampp\htdocs\final\testq.php on line 14
Can anyone solve this problem? Is it because i am using Word 2007?
© Stack Overflow or respective owner