1

I'm currently writing a docx generator in PHP. It creates tables, images, paragraphs e.g. and saves everything in the correct structure to a .zip (.docx). Now i need to include some macros into that .docx.

I have the macros in a .dot Template on a network drive, which is accessible for my .docx documents. How can I link that Template to my .docx-File?

Important: I need an approach to link the .dot file in the source of the .docx file. The macros should be automatically added in every .docx my Web-Tool creates for users.

Thanks for every advice

  • Hey, have a look at https://github.com/edi9999/docxtemplater, it has probably very similar functionality to what you're trying to build, and it's open source MIT. I will respond to your question below – edi9999 Nov 30 '13 at 14:21

2 Answers2

0

When adding a macro to a docm file, it results in three new files:

enter image description here

/word/_rels/vbaProject.bin.rels

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.microsoft.com/office/2006/relationships/wordVbaData" Target="vbaData.xml"/></Relationships>

and vbAData.bin

and vbaProject.bin

I suggest you to create a file with a macro to see what's in there.

edi9999
  • 19,701
  • 13
  • 88
  • 127
0

I would like to add that there's an easy way to create docx templates: Using a library I have created and I actively maintain:

https://github.com/edi9999/docxtemplater

Hope that helps

edi9999
  • 19,701
  • 13
  • 88
  • 127