I'm generating MS Word .docx files with COM (Component Object Model) using Find/Replace method on a template document.
The problem: it works fine on my PC, but I can't get it work on the production PC!! I have same configuration on both computers.
First I instantiate a COM object $word = new COM('word.application');
echo "Loaded Word, version {$word->Version}
";
says 12.0. So I deduce everything is ok so far.
Something goes wrong on $word->Documents->Open("c:\\test.docx");
command. It look's like whatever I put between the brackets is not passed through. Just the same as I'd put $word->Documents->Open(" ");
On the next line: $word->Selection->Find->ClearFormatting();
I get the error message:
"Trying to get property of non-object " and a fatal error after that. It looks like an empty string is passed in Documents->Open()
and the COM object is destroyed.
I tried relative, absolute paths, backslashes, double slashes... and it look's like it doesn't have anything to do with it.
As well the command $word->visible = 1;
doesn't bring word up.
There is more or less the same configuration on both PCs : 1st PC: - win7 Ultimate,32-bit, ms Word 7, same WAMP version 2nd PC: - win7 Professional,32-bit, ms Word 7, same WAMP version
I tried macros on the second PC, like: Documents.Open FileName:="test.docx" etc. and it works fine. I have no idea what is different on the second PC and what could possibly be the cause.