Forum


Replies: 6   Views: 1496
Conversion plugin based on ms word: transformdocument error ms word
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by dev-info  · 19-02-2021 - 12:39

hello, 

when i try to transform doxc to pdf, i have this error, :

Failed to create COM object `word.application': Une ouverture de session spécifique n'existe pas. Elle est peut-être déjà terminée.

can you help me?

Thank you

Posted by admin  · 19-02-2021 - 14:30

Hello,

That seems a generic error when PHP can't connect to MS Word or use the COM extension. We recommend you to test the PHP COM Extension standalone with the most simple available on the PHP documentation pages (https://www.php.net/manual/en/book.com.php) and also test using PHP CLI mode to check if there's some permission error or missing setup.

Regards.

Posted by dev-info  · 22-02-2021 - 07:47

Thank you for your response,

but php_com_dotnet.dll is active on wamp server (php.ini and dll present in ext fodler to php version on wamp server.

this is my code: 

   $docx = new Phpdocx\Create\CreateDocxFromTemplate("C:\\wamp64\\test\\test\\BE.docx");

try{

    $docx->createDocx("C:\\wamp64\\test\\BE2.docx");

    $docx->transformDocument("C:\\wamp64\\test\\BE2.docx", "C:\\wamp64\\test\\BE2.pdf");

}catch(Exception $e){

    validationGestionBase::message_log($e->getMessage());

}

Posted by dev-info  · 22-02-2021 - 07:49

for to create docx, no problem, that is work.

just for to transform docx to pdf

Posted by admin  · 22-02-2021 - 11:42

Hello,

Please note we are not saying that the PHP COM extension isn't installed but that some missing permision or connection set up is missing when doing the conversion using MS Word. As you are getting a generic error, we don't know where the issue may come from.

As you are using the conversion plugin based on MS Word, after you have tested that MS Word is installed in your server and can run correctly, we recommend you to test the PHP COM Extension standalone with the most simple sample available on the PHP documentation pages (https://www.php.net/manual/en/book.com.php) and test it using PHP CLI mode (instead of Apache or the web server you are using):

$ php test.php

to check if there's some permission error or missing setup in the web server that blocks PHP to call MS Word through PHP COM. Generating DOCX is done only with PHP, but the conversion plugin based on MS Word uses PHP with PHP COM and MS Word, so the permissions to be applied may not be the same.

Regards.

Posted by dev-info  · 23-02-2021 - 08:52

Hello,

Thank you to your answer.

I tested PHP CLI well, it works fine.
It is a local windows machine working with Wampserver.
the PHP version is 7.3.21.
I put all the possible authorization. I have the active php_com_dotnet DLL. on another pc, with the same config, it works fine. how to check if PHP COM works well in this case? for the office version, it's the 2019 pro plus.
I don't know what to try to make it work :( ..

Posted by dev-info  · 23-02-2021 - 11:24

ok i just found the solution, if it can be useful to other person:


Execute "dcomcnfg"
Open Component Services> Computers> My Computer> DCOM Config
Search for Microsoft Office Word 97-2003 Document (it will be something like this translated to your language, so take a while and search for it) <- Stuck at this one, can't find anything called "Microsoft Office ... "
Right-Click on it and open the properties
Choose "Identity" tab
Normally this is set to "the launching user". You have to change this to "the interactive user" or a admin user of your choice.
Apply these new settings and test your COM application. It should work fine now.

 

On my old computer, the office version was 2016, maybe this permission differs between the 2016 and 2019 version.


Thanks to the adim for following my problem


solution found on this topic:

https://stackoverflow.com/questions/12104775/cant-open-word-doc-with-com-in-php