I've been trying to automate opening and populating a Word file on network but came across an issue when trying to open the file from a mapped network drive. I can open the file from my c:\ drive and I changed the Apache settings to run as a user rather than as a local service. The script runs perfectly well in the Zend environment doing everything it should but on Apache it reads the target directory but cannot open the file using COM. (The directory is a Linux network storage device and I do have read/write access.)
try {
com_load_typelib('Word.Application');
$word = new COM("Word.Application") or die ("Can't start Word");
$word->visible = 1;
$handle = opendir('\\\\<host ip addy>\\<sharename>\\<directory>');
echo $handle . "\n";
while (false !== ($file = readdir($handle))) {
echo "$file\n";
}
$word->Documents->Open("\\\\<host ip addy>\\<sharename>\\<directory>\\test.doc");
$word->Documents[1]->Close();
$word->Quit();
$word=null;
} catch (com_exception $ce) {
echo $ce->getMessage;
}
I'd be grateful for any thoughts on solving the issue.