Replies: 2   Views: 158
Generated docx with macro not opening

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


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');


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] the file, we'll check it.


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

Thank you for replying. This might help us further.