Forum


Replies: 2   Views: 970
Generated docx with macro not opening
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@ams  · 08-06-2020 - 14:11

Hi there,

We have created a .dotm with a macro that we use to generate a new .docx file with phpdocx that should contain this macro. If we open this .docx in LibreOffice, it open (but with warning). However, in Word, it won't open at all, without any warning or message. Is this a known issue?

Posted by admin  · 08-06-2020 - 15:14

Hello,

A DOCX that contains a macro must have docm extension, not docx, otherwise it thows an error when opening it with MS Word or LibreOffice. The following code generates a document with a macro (examples/LayoutAndGeneral/addMacroFromDoc/sample_1.php):

$docx = new CreateDocx('docm');

$docx->addMacroFromDoc('../../files/fileMacros.docm');

$docx->createDocx('example_addMacroFromDoc_1');
rename('example_addMacroFromDoc_1.docx', 'example_addMacroFromDoc_1.docm');

There's no known issues when importing macros or using a document that contains one or more macros. If you send to contact[at]phpdocx.com the file, we'll check it.

Regards.

Posted by dev@ams  · 09-06-2020 - 09:12

Thank you for replying. This might help us further.