Windows 7 Professional x64 - WAMP Server 2.4
Apache Version (x32): 2.4.4
PHP Version (x32): 5.4.16
Office 2003 - Same version as old server
I have a legacy program that reads local .doc files on a shared drive, inserts content into bookmarks, and then saves these files before they are converted to .pdfs and emailed to our clients. Before anybody else tells me, I am VERY AWARE that this is not a recommended or supported way to do things. Just need to get this legacy code working on new hardware so I can finish work on a newer piece of software that will eventually replace this and avoid COM scripting all together.
Recently the server that runs this software has become unbearably slow. We're setting up a new server to move it over to, but I've encountered a show-stopping critical error with the software on the new environment:
The following code WORKS AND HAS NO PROBLEMS:
// starting word
$word = new COM("Word.Application") or die("Unable to instantiate Word");
echo "Loaded Word, version {$word->Version}
";
$word->Visible = 0;
//open an empty document
$word->Documents->Add();
$word->Selection->TypeText("This is a test...");
$word->ActiveDocument->saveAs('C:\test.doc');
echo "File saved
";
//closing word
$word->Quit();
//free the object
$word = null;
echo "Word closed
";
The following code just hangs forever and never gets past the $word->Documents->Open(); line.
// starting word
$word = new COM("Word.Application") or die("Unable to instantiate Word");
echo "Loaded Word, version {$word->Version}
";
//bring it to front
$word->Visible = 0;
$word->Documents->Open('C:\test.doc') or die ('Could not open file');
//closing word
$word->Quit();
//free the object
$word = null;
echo "Word closed
";
PLEASE HELP! Seeing that the PHP/COM can create a new file and save it makes me feel like this is possible, but there's some permissions issue hiding behind the scenes preventing Word from opening existing files.
Apache services need 1 window account have permission network to start it. Simple you need start apache via command to test.