Re: php5.1RC/COM/Word

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



George Pitcher wrote:
Hi,

My dev machine has PHP 5.1RC installed (no problems so far, apart from
this), its on Win XP. My server is running PHP 5.0.4 on Win NT.

I'm building some MS Word docs and it works fine except when I need to add
something that uses more than one parameter - eg.:

$word->Selection->ParagraphFormat->TabStops->Add->Position(418,0,0);

Whenever I use something that needs more than one parameter, I get my Word
document generated up to that point and an error message on the web page:
"PHP Fatal error: Uncaught exception 'com_exception' with message 'Error
[0x8002000e] Invalid number of parameters.'".

you should be using a try/catch block (lets assume for now that the error
msg is correct and COM is not broken as such):

try {
	/* do stuff ... e.g. */
	$word->Selection->ParagraphFormat->TabStops->Add->Position(418,0,0);
} catch (com_exception $e) {
	print_r($e); // or do some better error handling
}

catching the exception will give you the opportunity to continue the
script (rather than having to swallow a fatal error) - the fact that your
getting an exception is either because you really are using the wrong
number of parameters or the COM extension is broken in 5.1 (I guess -
maybe check bugs.php.net to see if someone has filed anything regarding this)

btw there is also the keyword 'throw' that complements try/catch - the manual
explains the basics of exception throwing and catching much better than I
can (be bothered to ;-)


Does anyone know of a solution?

No smart-Alec replies please.

thats kinda asking for it ;-)

"stop your fatal error; don't run the script; garanteed to work
on all platforms"


cheers

George in Oxford


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux