Hello,
I have a PHP script running on XAMPP in Windows XP that will open a .doc file and then save it as a different copy. This was working fine earlier on, but out of nowhere the error message keeps appearing.
$path = "c:/xampp/htdocs/";
com_load_typelib('Word.Application');
$word = new COM("word.application") or die("Unable to instantiate Word");
$word->Documents->Open($path."tmp/invoice.doc");
$bookmarkname = "InvoiceNo";
$objBookmark = $word->ActiveDocument->Bookmarks($bookmarkname)->Range->Text = "INVOICE ID";
$word->Documents[1]->SaveAs($path."tmp/invoice2.doc");
$word->ActiveDocument->Close(false);
$word->Quit();
$word = null;
I feel that the code is not the problem, as it was working a few hours ago, but now isnt. I suspect it is something to do with my Word 2003, prehaps somethings caused it to bug out.
I have tried rebooting, clearing temp folder as described on the Microsoft website.
I can still write to the folder by using file_put_contents, so MAYBE if I could extract the raw data from the $word->Documents[1] then I could use file_put_contents to save it instead of using Word's save function. The problem is that this is quite poorly documented so I cant find a list of available functions available to me to do that.
Any help, thoughts would be greatly appreciated!