Re: Fwd: Code Optimization Help
| From: | Jochem Maas | Date: | Wed, 21 Sep 2005 11:39:41 +0000 |
| Subject: | Re: Fwd: Code Optimization Help | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-222861@lists.php.net to get a copy of this message | ||
Joseph Crawford wrote:
Ok so finally i implemented my logging class into my mail merge object, this is the results Word -> Application Opened. Word -> Document1 Document Added. Word -> header.doc Document Saved. Word -> header.doc Document Closed. Word -> Document2 Document Added. Word -> ds.doc Document Saved. Word -> ds.doc Document Closed. Word -> Has_Site.dot Document Opened. Word -> Opening Header Source. F:/htdocs/csaf/data/mailmerge/header.doc File Exists I threw in a file_exists check to make sure the script was actually seeing the file and had the correct path. It does. This is very strange because nothing happens, it's like i hit a never ending loop but php never times out either. I have my php timeout to 30 seconds yet this has run in excess of 5 minutes now.if you run php on the cmdline there will be no timeout. I am helping you blind here btw (I know nothing about COM) but I suggest you try is_readable() as well as file_exists() - maybe the current user (that php/Word is running at) is not allowed to read the file?
The expected results for the log would look something like this Word -> Application Opened. Word -> Document1 Document Added. Word -> header.doc Document Saved. Word -> header.doc Document Closed. Word -> Document2 Document Added. Word -> ds.doc Document Saved. Word -> ds.doc Document Closed. Word -> Has_Site.dot Document Opened. Word -> Opening Header Source. F:/htdocs/csaf/data/mailmerge/header.doc File Exists Word -> Opening Data Source. Word -> Executing Merge. Word -> Has_Site.doc Document Saved. Word -> Has_Site.doc Document Closed. Word -> Merge Successful. The code that is hanging is below private function CreateDocument($template) { $this->obj->Documents->Open($this->mm_data_dir.'/'.$template.'.dot'); Logger::log('Word -> '.$this->obj->ActiveDocument->Name().' Document Opened.'); Logger::log('Word -> Opening Header Source.'); if(file_exists($this->mm_data_dir.'/header.doc')) { Logger::log($this->mm_data_dir.'/header.doc File Exists'); } // THIS IS THE LINE THAT HANGS, THE FILE EXISTS AND IS POPULATED THE FILE CONTENTS CAN BE SEEN HERE http://codebowl.dontexist.net/bugs/MailMerge/3.jpg$this->obj->ActiveDocument->MailMerge->OpenHeaderSource($this->mm_data_dir.'/header.doc'); Logger::log('Word -> Opening Data Source.'); $this->obj->ActiveDocument->MailMerge->OpenDataSource($this->mm_data_dir.'/ds.doc'); Logger::log('Word -> Executing Merge.'); $this->obj->ActiveDocument->MailMerge->Execute(); $this->obj->ActiveDocument->SaveAs($this->mm_data_dir.'/'.$template.'.doc'); Logger::log('Word -> '.$this->obj->ActiveDocument->Name().' Saved.'); Logger::log('Word -> '.$this->obj->ActiveDocument->Name().' Document Closed.'); $this->obj->ActiveDocument->Close(); } Any help with this would be appreciated. I am not sure why it is choosing to hang today ;( I have been going through the COM object API documentation and i dont see myself doing anything i shouldnt be doing. You can see the full code here http://pastebin.com/369068 that is if it hasnt expired, if so send a reply and i will post again ;) Thanks in advance