dingleberry
Programmer
Hi. I've been trying to figure out how to create a word document from php. I've been combing the internet and came across this snippit.
<?
// create a reference to a new COM component (Word)
$word = new COM("word.application"
or die("Can't start Word!"
;
// print the version of Word that's now in use
echo "Loading Word, v. {$word->Version}<br>";
// set the visibility of the application to 0 (false)
// to open the application in the forefront, use 1 (true)
$word->Visible = 1;
// create a new document in Word
$word->Documents->Add();
// add text to the new document
$word->Selection->TypeText("Testing 1-2-3..."
;
//save the document in the Windows temp directory
$word->Documents[1]->SaveAs("c:/comtest.doc"
;
// close the connection to the COM component
$word->Quit();
// print another message to the screen
echo "Check for the file...";
?>
when I execute it I get this echod to my browser.
Loading Word, v. 8.0
Warning: (null)(): Invoke() failed: Type mismatch. Argument: 2 in c:\program files\apache group\apache\htdocs\test.php on line 17
Warning: (null)(): Invoke() failed: Type mismatch. Argument: 2 in c:\program files\apache group\apache\htdocs\test.php on line 20
Check for the file...
Any ideas on why I'm getting those errors?
Thanks,
Dan
<?
// create a reference to a new COM component (Word)
$word = new COM("word.application"


// print the version of Word that's now in use
echo "Loading Word, v. {$word->Version}<br>";
// set the visibility of the application to 0 (false)
// to open the application in the forefront, use 1 (true)
$word->Visible = 1;
// create a new document in Word
$word->Documents->Add();
// add text to the new document
$word->Selection->TypeText("Testing 1-2-3..."

//save the document in the Windows temp directory
$word->Documents[1]->SaveAs("c:/comtest.doc"

// close the connection to the COM component
$word->Quit();
// print another message to the screen
echo "Check for the file...";
?>
when I execute it I get this echod to my browser.
Loading Word, v. 8.0
Warning: (null)(): Invoke() failed: Type mismatch. Argument: 2 in c:\program files\apache group\apache\htdocs\test.php on line 17
Warning: (null)(): Invoke() failed: Type mismatch. Argument: 2 in c:\program files\apache group\apache\htdocs\test.php on line 20
Check for the file...
Any ideas on why I'm getting those errors?
Thanks,
Dan