Forum


Replies: 2   Views: 1459
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 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.