Page 1 of 1

error

Posted: Mon Jan 16, 2012 7:55 am
by kkr653
hello i have run the following code
but it gives error mesage

Fatal error: Cannot pass parameter 1 by reference in F:\wamp\www\dddddddddd\worddd.php on line 13

code is

<?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("anp.doc");

//closing word
$word->Quit();

//free the object
$word = null;
?>

Re: error

Posted: Mon Jan 16, 2012 9:37 am
by twinedev
Not sure here, but i know that where I used to work, when one of the servers was upgraded to a new version of PHP, we had to dump some older Joomla installs onto an older server because of changes in new version. Forget offhand what version and/or what it was causing this, but that would be my guess that if you are using code from a tutorial somewhere and you are getting this, that the tutorial was written for an older version of PHP.

The issue is that it is expecting you to give something that can be referenced, (ie, a variable), not an actual literal value (the hard coded strings)

For your issue, I would try assigning "This is a test..." and "anp.doc" to variables, then use variables in the two lines where they are used. (not sure which one is line 13, so doesn't hurt to do it for both)

-Greg