php - COM('word.document') open in read only whilst file is opened by other -


i'm using php , try fiddle around com objects read word files. getting litereally finding documentation.

what want open file in read dont "file in use" popup on host computer.

how tell word via com open file read only? trying use variants following error:

parameter 0: type mismatch. #0 c:\xampp\htdocs\test.php(17): variant->open('\\remote\test\test.doc', false, true, false, object(variant), object(variant), object(variant), object(variant), object(variant), object(variant), object(variant), true, true, object(variant), object(variant), true) #1 {main}

this code use

$word = new com("word.application") or die("unable instantiate application object");  $worddocument = new com("word.document") or die("unable instantiate document object"); $missing =  new variant();  $word->visible = 0; $documentpath = "\\remote\test\test\alamo.doc"; $htmlpath = ""; try { $worddocument = $word->documents->open("\\exit-dc\eeb\test\alamo.doc"/* filename */, false/* confirmconversions */, true/* readonly */,                                      false/* addtorecentfiles */, $missing/* passworddocument */, $missing/* passwordtemplate */,                                      $missing/* revert */, $missing/* writepassworddocument */, $missing/* writepasswordtemplate */,                                      $missing/* format */,$missing/* format */, $missing/* encoding */, true/* visible */, true/* openconflictdocument */,                                      $missing/* openandrepair */, $missing/* documentdirection */, true/* noencodingdialog */);  $htmlpath = substr_replace($documentpath, 'html', -3, 3); if($worddocument !== null) {     $worddocument->saveas($htmlpath, 3);//3 = text, know. } } catch(exception $ex){     echo $ex->getmessage() . $ex->gettraceasstring(); } $worddocument = null;  $word->quit();  $word = null; 

what want? open file read flag. want read it. know can providing filename only, works, need work multiple instances reading same file.

for intents , purposes should work. php should cast string , booleans proper variant types , empty variant types should fill place of system.reflection.missing.value

i used https://msdn.microsoft.com/en-us/library/office/ff835182(v=office.14).aspx (word 2010) compile list of arguments needed, , reading through comments on http://php.net/manual/en/book.com.php find workable solution...

the solution seems work far making copy, open that, read it, delete copy. me thats least desirable option because should know, work. plenty of c++, vb, .net etc... examples of how works, php refuses accept parameters. doing wrong?

just 1 question why use com, not recommended use on server in context of php should instead try reading word 2007/2010 .docx files nothing xml files , avoid hassels together


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -