Multiple loops in the same Microsoft Word document?

Make gives us the ability to insert 1 loop in a Microsoft Word document, but Make does not give us the ability to insert 2 different loops in a Microsoft Word document.

Are there any known workarounds to this issue?

Here is a more technical description of this problem:

Whenever we have a loop in our Microsoft Word module (for inserting a loop into a Word document), we always place an iterator before the Microsoft Word module.

Our iterator loops through our array of data, because the Microsoft Word module is expecting us to send it multiple bundles to create the loop.

However, we are unable to have 2 completely different loops (i.e. 2 completely different iterator modules) feeding into the same Microsoft Word document.

That’s because as soon as we send data to a Microsoft Word document ONCE, Make clears out all the other tags that are in the Word document, so we don’t have the ability to send another set of bundles into the exact same Microsoft Word document.

Is there any known methods or workarounds to get 2 loops of data (i.e. 2 different sets of bundles) feeding into the same exact Microsoft Word document?

If Make gave us the option to “not erase tags” in Microsoft Word documents, then we could continue to send additional loops of data into the same document.

But since we don’t have that as an option, are there any other known workarounds to insert 2 different loops within the same exact Microsoft Word document?

Thanks!

1 Like

What do you mean by “loop”? Did you mean to Iterate an array of data so that the module runs multiple times?

If you need further assistance, please provide the following:

1. Screenshots of module fields and filters

Please share screenshots of relevant module fields and filters in question? It would really help other community members to see what you’re looking at.

You can upload images here using the Upload icon in the text editor:
Screenshot_2023-10-07_111039

2. Scenario blueprint

Please export the scenario blueprint file to allow others to view the mappings and settings. At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.

Screenshot_2023-08-24_230826
(Note: Exporting your scenario will not include private information or keys to your connections)

Uploading it here will look like this:

blueprint.json (12.3 KB)

3. And most importantly, Input/Output bundles

Please provide the input and output bundles of the modules by running the scenario (or get from the scenario History tab), then click the white speech bubble on the top-right of each module and select “Download input/output bundles”.
Screenshot_2023-10-06_141025

A.

Save each bundle contents in your text editor as a bundle.txt file, and upload it here into this discussion thread.

Uploading them here will look like this:

module-1-input-bundle.txt (12.3 KB)
module-1-output-bundle.txt (12.3 KB)

B.

If you are unable to upload files on this forum, alternatively you can paste the formatted bundles in this manner:

  • Either add three backticks ``` before and after the code, like this:

    ```
    input/output bundle content goes here
    ```

  • Or use the format code button in the editor:
    Screenshot_2023-10-02_191027

Providing the input/output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

Following these steps will allow others to assist you here. Thanks!

2 Likes

No, I am referring to the built-in loop creation feature of the Microsoft Word module.

It is documented by Make here.

Creating loops is one of the built-in features of the Microsoft Word module.

However, the problem is that due to either bugs or limitations in Make, it seems like Make only supports one loop, with no ability to add 2 loops per Microsoft Word document.

If this is possible, I would love to know how to do this.

If this is not possible, I would love Make to add this as a feature to the Microsoft Word modules.

2 Likes

I’ve written a summary of the problem here, and other people can upvote my suggestion:

https://www.make.com/en/app-improvement-ideas/p/microsoft-word-templates-should-support-multiple-loops-per-document

Here is the summary of the problem:

The Microsoft Word templates allow us to insert ONE loop of “table data” per document.

This is fully documented by Make on this page: https://www.make.com/en/integrations/docx-templater

However, when creating lengthy Word documents, we often need to insert MULTIPLE DIFFERENT LOOPS of “table data” per document.

But, due to either bugs or limitations with Make’s Microsoft Word modules, Make doesn’t seem to give us any opportunity to insert MULTIPLE DIFFERENT LOOPS of “table data” per document.

That’s because once you use the Microsoft Word module ONCE, Make erases all the other tags in the Word document. So you can’t go back and update a document later with an additional loop.

Can this experience please be fixed and/or improved, so we can create lengthy Word documents with MULTIPLE LOOPS within the same document?

Thank you!

Scott

3 Likes

Hi @ScottWorld,

not sure if that helps but I was facing a similar issue. Somehow I guess there is a better solution but for me the following work-around fixed the issue:

In the advanced settings of the the microsoft word module there is the option to customize the delimiters. So in the first loop I used the standard delimiters {{/}}. Then I stored the document in a variable (not need to upload or download) and called it again later in the scenario into another word module. There I used [[/]] as delimiters in the loop.
With the different delimiters in the word template they were not overwritten by the first loop.

I think this helps if you need to loop multiple times for different tables (that is my use case) and maybe it helps you too.

5 Likes

Oh wow, @Martin_Ebel!

That is a fantastic workaround and the perfect solution to get around this bug in Make!!

I didn’t even realize that we could change the delimiters by enabling the advanced options!!

For those Make employees who are reading this thread, the bug in Make is that it wipes out all empty delimiters after running the module once, so we can never re-use a Microsoft Word document.

Thank you so much, @Martin_Ebel, for coming up with the best trick ever for working around this problem in Make!! :smiley::raised_hands:

Best,
Scott

3 Likes

Update with another solution:
I have to work with many different tables in my scenario. With the solution I proposed above my scenario got more and more complex with a lot of routes (I started to work with placeholders like {1{...{1}, {2{...{2}).

Therefore I invested more time in finding a better solution and I found a solutions that let’s you create multiple tables with a single component by using a json file as input. This is partly described in the documentation for the word module but it took me a while to figure out the exact json format needed.

My example document with two different tables looks like the following. As you can see I created a loop called country_carrier and a loop called warehouse_list:

In order to fill both tables at the same time I use the word module Fill out a document with a batch of data and a JSON file that contains the data for both tables. Please see the screenshot below:

I first create a JSON (next step for me is to automate the json creation but there are other help articles on that one). The example json I used:

JSON Example
[
  {
    "key": "country_carrier",
    "value": [
      {
        "entry": [
          {
            "key": "country",
            "value": "AT"
          },
          {
            "key": "carrier",
            "value": "Post AT"
          }
        ]
      },
      {
        "entry": [
          {
            "key": "country",
            "value": "CH"
          },
          {
            "key": "carrier",
            "value": "Post CH"
          }
        ]
      }
    ]
  },
  {
    "key": "warehouse_list",
    "value": [
      {
        "entry": [
          {
            "key": "warehouse",
            "value": "Outbound"
          },
          {
            "key": "city",
            "value": "Berlin"
          },
          {
            "key": "loading_spec",
            "value": "Gate 1"
          }
        ]
      },
      {
        "entry": [
          {
            "key": "warehouse",
            "value": "Inbound"
          },
          {
            "key": "city",
            "value": "Wien"
          },
          {
            "key": "loading_spec",
            "value": "Gate 4"
          }
        ]
      }
    ]
  }
]

After aggregating it to an array and saving it as a variable I called this array again and iterate over it before using it in the word document as indicated in the screenshot.

By this approach I get both tables created at the same time in one module:
image

5 Likes