Mail Merge for PowerPoint

Until recently Microsoft PowerPoint lacked a tool that acts like the mail merge functionality for Word. But now there is SlideMight. In this article I show how you can fuse a flat data set with a PowerPoint presentation. In a follow up, I'll present more advanced features such as image handling.

We present a use case that has been inspired on George Mount's example on his blog post "Excel Tip: Mail Merge to PowerPoint via Word Outline". We use files in a folder named MailMergeDemo residing in the "Examples" archive that you can download from the SlideMight web shop (click menu bar at the top). These files are:

  • MailMergeDemo_pattern.pptx: a Powerpoint presentation with so called pattern slides
  • default_config.json: a default configuration
  • MailMergeDemo_config.json: a specific configuration
  • MailMergeDemo_data.json: a data set: 6 persons with their names, hometowns and favorite colors

Below you will see part of the contents of the data file and the specific configuration file.

Pattern slide 1

In the first pattern slide there are two so called "placeholders", that start with a $ symbol followed by some text between braces. When SlideMight makes a new presentation based on the pattern file and data, it will process such placeholders. Often they will be substituted by some specific text:

  • ${Persons.COUNT} – to be be substituted by the number of records in a list named Persons in the data set
  • ${DATE_TIME:yyyy-MM-dd HH:mm} – to be substituted by the current date and time, in the specified format

The Persons list in the JSON data file looks like:

{
  "Persons": [
   {
     "Name": "Bob",
     "Hometown": "Cleveland",
     "Fav Color": "Blue"
  
},
   ....

  ]
}

("..." stands for 5 more person records)

SlideMight is normally operated from a graphical user interface (GUI), but command line operation is also supported, and there is also an application programming interface (API).

 

In the GUI you specify the working folder, a media folder for images, the pattern file, the specific configuration file, the data file and the output file.

As soon as a valid pattern file is specified, this is analysed, and then structural details appear in the upper table. After processing the table also lists the numbers of generated slides. Error messages, if any, will appear in the lower table (if none, you see "No content in table").

The first slide in the resulting presentation is:

 

Pattern slide 2

The next pattern slide aims to mimic the mail merge functionality of Microsoft Word.

The main difference with the first pattern slide is that at the top there is a text field with a special placeholder: ${FOR_ALL: Persons}. In the resulting presentation a slide will be present for each record in the Persons list.

On each such slide in the resulting presentation the name, home town and favorite color have been substituted for the placeholders ${Name}, ${Hometown}, ${Fav Color}.

Pattern slide 3

Up to here it was just like mail merge. SlideMight offers much more. Suppose for instance that we want to show the favorite colors not only as text, but also as colored areas. That is possible for placeholders that are positioned in table cells.

First we have to define the specific representations in a "formats table". On the top of this pattern slide, the placeholder ${FORMATS} tells that the slide contains a so called "formats" table; and this slide will not appear in the resulting presentation.

The formats table defines named formats, and in the next columns there are specific string values together with their desired representations. Here the named format is "asColor".

Pattern slide 4

We use this "asColor" format in the next pattern slide. This specifies again an iteration over the Persons list.

The lower right cell of the table contains ${Fav Color: asColor}. "asColor" is the special format name defined in the formats table on the previous slide. Thus the corresponding cells in the generated slides will show the full favorite colors.

The cells in the second column contain just "$$". These are special shorthand placeholders. There is a configuration file that defines the meaning of these shorthands in their context (here: "Persons"), and based on a label, which is by default the text in the neighbouring cell to the left. E.g., the first "$$" has to the left the label "Name". Let's look up this label in the context of "Persons" in the configuration file: 

{

  "formats": {
    "DATE_TIME"    : "yyyy MM dd hh:mm" // overrides default
  },

  "aliases": {

   // map from entity list names to
   // maps from alias names to strings that typically contain placeholders

     
"Persons": {
        "No."                   : "${ROW_NUMBER}",
        "Name"               : "${Name}",
        "Hometown"       : "${Hometown}",
        "Favorite Color" : "${Fav Color}"
      
}
   }
}

So according to the configuration file this "$$" is shorthand for "${Name}". That happens to be a normal placeholder, which will be replaced by the current person's name.

We have also created hyperlinks for two cells in the table. Both definitions are: https://en.wikipedia.org/wiki/$$. The generated hyperlinks will point to the Wikipedia pages on items named by hometown and the favorite color.

At the top of the template slide the placeholders ${ROW_NUMBER} and ${COUNT}, with the slash in between, result in "1/6", "2/6", ..., "6/6" (assuming there are 6 data records). 

Pattern slide 5

It is also possible to list all elements of a data set in so called "entity tables".

For such a table we must state that in the Description property. This is reachable in PowerPoint from the "Format object" popup menu, and then in the "Alt Text" pane.

For the table of this pattern slide we put in the placeholder $ {FOR_ALL: Persons} as description.

There may be too many records present to fit in a given table on a single slide. In such cases the table will be split over multiple slides; i.e. records will continue on a cloned table on the next slide. There the table will start with a row to mark that it was continued from an earlier slide, and the table on the previous slide will get a row to mark that it is continued on the next slide.

The table on the shown template slide may hold up to 4 data rows, which happens to be not enough for the list of 6 persons. The rows for signalling continuation are small, with in red "(Continued)";  "(To be continued)".

The hyperlink on "$$" in the Name column in the template slide has as definition "#4". The corresponding links in the generated table will point to the appropriate slide that has been generated for template slide 4, i.e. a slide with a small table presenting the details of the person with that name.

Conclusion

We have shown how you can do mail merge like operations in SlideMight. Within tables SlideMight offers more advanced features:

  • define formats that map data values to specific representations
  • use convenient shorthand placeholders "$$"
  • entity tables in which for each data record a rows is generated
  • such entity tables may overflow to cloned slides, when applicable

There is more to SlideMight, e.g.,

  • iterations within other iterations, e.g. Persons, Hobbies, Photos
  • image substitution and images in tables, from files, URLs or raw data

These features will be covered in later blog posts.