DOCX
If you work with documents and you want to automate them, an in-depth knowledge of the .DOCX file type is essential.
DOCX files are essentially zip files. So much so in fact you can change the file type of your file from .docx to .zip. And then open the resulting zip folder. You'll see a collection of folders and files. These contain all the formatting and images in your document. There's one file that holds the content of your document. This is document.xml. You can open it and you see an XML tree of elements describing the contents of your document. It's a bit like HTML. Actually HTML is a subset of XML. So you see container tags. These come in pairs that open and close. And inside there are child containers. So you'll see a document that contains sections. Sections contain paragraphs. Paragraphs have a run of words. These can have properties like font and bold and underline. You might also see a table in your document with rows. These rows have cells.
You could actually edit this XML yourself. Then zip your set of folders back up and rename your file back to .docx. Open the document in Word and if you did everything right you can see the change you made. Isn't this powerful?
There's a Chrome extension called OOXML Tools that makes it super easy to do what I just described. Install it in Chrome and click on it. It says to drag a DOCX file onto the browser screen. It presents you with the tree of folders and files. Click on document.xml and you can edit it in the browser. Make your changes and there is a button to instantly download the new DOCX file. Super easy to make modifications and test your changes!
How can we use this in automation? Well, imagine giving your user a form (We have such a form shown below that you can try for yourself!). Perhaps their name, today's date, their favorite ice cream flavor. Everything you want in a resulting document. When they submit the form, we put all the data into the DOCX file. You can give this automatically generated DOCX file to your requester to submit further or submit it immediately to your team to review. Or upload it to your repository. This makes it so your user can fill in a document indirectly. They fill in a document by filling in a form. You only allow your user to edit your document in exactly the way you want them to edit it. Super powerful stuff.
Let's do an example form where the user can type in data that we will put into the DOCX. First we start with the DOCX template which you can find here. Shown below.
Form
Fill in your name and favorite food and submit to get your new DOCX file


Fill in your name and favorite food above and click Submit. Did you get your automatically generated DOCX file?
Comments
You must sign in to comment
We use cookies to help run our website and provide you with the best experience. See our cookie policy for further details.