Hello there, I want to add text paragraphs with line breaks in the microsoft word template module.
In the help doc for word templates it says: “The Microsoft Word Templates app accepts only single-line plain text for replacement values. When adding line breaks, they will be viewed as spaces and won’t affect the formatting of the text.” (https://www.make.com/en/help/app/microsoft-word-templates)
Is there any workaround or way to still get in text paragraphs with line breaks? I desperately need this function. Thank you!
This is the exact problem I am facing with. I tried splitting and aggregating the original plain text in many ways, I also transformed it into different formats (rich text, markdown, HTTP, unicode), with zero result.
Another thought about this, why not try making your template in Google Docs then downloading the file as DOCX? If DOCX isn’t the final format, then download as PDF is another option.
The final document might look a little different than what Word would produce, but it is something to consider!
Hi Donald, I thought about it, and it would make sense when personal use. The issue comes when the client is a company that runs all its data in a Microsoft environment. They won’t change the whole ecosystem for the sake just one bot.
Btw I found a some sort of ‘workaround’. I insert the plain text in a MS Excel Workbook because (in contrary to Word) there are many Excel modules in Make. The formatting stays intact when putting a long text in a cell, although it’s not very handy if you want to edit the text later.
Dear Make Dev team: do us more Word modules pleeeease!
Here’s the best I could come up with so far, not sure if it would help yours or anyone else’s situations.
Here’s an example of my source text, the stuff I want plugged in to the template.
The tag list is a list of tags that should always be in my template document.
The Fixed Text is the text I wish to split up and put into my final document. Each line corresponds to each tag in the list, in order. Consecutive new lines count as a single new line so Fixed Text is effectively 4 lines.
Dynamic Text is multi-line and the number of lines may vary, but same thing, it’s effectively 4 lines.
You can see that since I only had effectively 4 lines of dynamic body text, only those 4 lines shows up in the document.
This only works if you have access to modify the template.
You’d have to place line break between multiple conditional tags.
To make it easier, they need to be named such that only a sequential number can make them unique (#hasLine1, #hasLine2, etc…)
The other caveat is that the lines that did not get filled show up as blank lines in the document, so basically just the conditional placeholders were replaced with nothing, but the newline remains in place.
Thank you Donald for taking the time to deal with this, it’s an interesting approach. Let’s say I have an LLM generated blog post or news article. How could I split it up to fixed/dynamic fields when each text has different structure?
@Donald_Mitchell I already tried creating a google doc and then converting it to a word doc, but there are quite a few problems with the conversion and layout. For example the automatic formatting of the table of contents doesn’t work after the conversion.
Do you have a couple example of different types of output?
The main issue here is that Microsoft’s Graph API doesn’t seem to offer any way to produce Word documents using API.
If you look at a DOCX file, it’s just a zip file containing several XML and other files that describe how to render the document.
Each block of text is represented by a new tag in the document.xml contained within the DOCX archive. Line breaks and other special characters are separate tags.
I’m not positive about how Make does it, but it appears Make it somehow constructing these files and not actually using any API. This would explain why it’s so limited and can’t do much more than just replace text.
Your best bet here is probably hosting your own API that can use something like Python and the python-docx library to build and upload documents according to instructions you provide via API calls from Make to your own server.
You can try this out in Make:
Download a DOCX file
Use Archive App to Extract Archive
Find the bundle that contains document.xml
Turn document.xml into text XML, parse it out, find the text you want to replace
Use Archive App to Create Archive with the same directory structure and your new document.xml