OOXML Hacking: Buy the ebook

The ebook version of OOXML Hacking has been released. The last three years have gone into adding the equivalent of 40 pages of new information. This is in addition to the trove of unique techniques that already appeared in the print version. Here are screen shots of the table of contents, to give you an idea of the topics covered in this publication:

Table of Contents 1
Table of Contents 2
Table of Contents 3

Barnes & Noble distributes only in the U.S., so use Kobo.com if you’re from another country.

As always, all techniques are covered in both Windows and Mac, where possible. The book contains a link to a downloadable text file of all listings in the book, so you don’t have to re-key text from the screen. The book is currently available on Kobo.com and Barnes & Noble. Barnes & Noble distributes only in the U.S., so use Kobo.com if you’re from another country.

Some have asked if they can use a Kobo book in a different reader. The answer is Yes! Here is Kobo’s page on how to download books from your Kobo account to export to another device or app.

Please note, this e-book has digital rights management applied. All code listings are available in a downloadable text file, so you don’t have to re-key anything. If you have any problems, please contact us at this address

Your Office Questions Answered – Best Practices

Brandwares provides top-quality, bulletproof templates to a world-wide clientele. We have the Client List to prove it. But you can get your Office questions answered for free (or cheap)!

I answer questions online about PowerPoint and Word for both Windows and macOS. For general questions about formatting and using both programs, visit the Answers.Microsoft.com Word or Answers.Microsoft.com PowerPoint forums. If you’re a VBA programmer working with Word or PowerPoint, you can get my help at the Stack Overflow Word or Stack Overflow PowerPoint pages.

I also answer questions at Experts Exchange, where I’ve been awarded a Distinguished Expert award for 2021.

Office Questions Answered - Experts Exchange Distinguished Expert 2021

This site isn’t free, but it is jam-packed with expertise. There’s a 7-day free trial, if you want to check it out. Tag your post with Microsoft PowerPoint, Microsoft Word, VBA and/or Fonts Typography to ensure your Office questions are answered.

Microsoft-Compatible PowerPoint Templates – Best Practices

The vast majority of presentations are created using the default templates that comes with Microsoft PowerPoint. All Microsoft-compatible PowerPoint templates have a uniform structure, and the result is that you can copy and paste slides between any deck and the paste works as expected: the content comes across perfectly, and the formatting is updated.

But in almost all corporate presentations with custom templates, this no longer works. Slides pasted from Microsoft-based presentations always need to be reformatted manually, because the custom template haven’t been created to be Microsoft-compatible.

It doesn’t have to be this way. Here’s how to create custom templates that will be both Microsoft-compatible and have a look and feel that is brand-compatible with the organization.


What’s in a Microsoft-Compatible PowerPoint Template?

Most designers create presentation templates incorrectly for the purpose of importing of slides created with Microsoft templates. Almost universal infractions include deleting or renaming the default slide layouts, and deleting or adding placeholders on whatever default slide layouts are left. Less common methods that designers use to wreck templates include deleting all placeholders on the master slide, and deleting all default layouts, then trying to replace them

To understand why these actions could cause problems, we need to understand the PowerPoint file structure. All new blank PowerPoint files contain the following:

  • 1 Master Slide (in Slide Master view, the larger slide at the very top of the left-hand thumbnail list). The parent to all the layouts, to which the slide layouts are children. All text formatting is inherited from this slide. Deleting placeholders here will cripple the template.
  • 11 default slide layouts, which inherit the formatting set in the master slide. These 11 comprise:
  • Title Slide, for the presentation title.
  • Title and Content, for the bulk of the presentation content.
  • Section Header, to divide the deck into relevant sections.
  • Two Content, with 2 content areas.
  • Comparison, similar to Two Content, but each content area also has a corresponding heading placeholder.
  • Title Only, displaying only a Title field, with the rest of the slide blank.
  • Blank, with not even a Title field.
  • Content with Caption, a little-used layout the includes a Title, Text and Content placeholder.
  • Picture with Caption, similar to Content with Caption, but with a Picture placeholder replacing the Content one.
  • Title and Vertical Text This layout is intended for Asian language use and is only displayed as a choice if your operating system has an Asian language set up.
  • Vertical Title and Text Similar to the previous layout, only visible on computers with Asian language input enabled in the operating system.
Mandatory default layouts (Asian-language-enabled system).
Microsoft-compatible PowerPoint Layouts

Each of these layouts has a specific layout type, set in XML and not alterable in the program interface. You can create the correct placeholder types by generating a new, blank PowerPoint file. Each of these layouts contains placeholders for the date and slide number, plus a footer field. All but 1 have a title placeholder.

Here’s the second line of a default Microsoft layout. In this example, obj is the XML type for a Title and Content layout:

<p:sldLayout xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"
type="obj" preserve="1">

If a slide layout has been created by the user from the Insert Layout command, that layout will not have a type. Instead, the second line of the XML will include userDrawn=”1″:

<p:sldLayout xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"
preserve="1" userDrawn="1">

PowerPoint reads the userDrawn property and will not treat your layout as a default layout no matter what you do to it. It will never be Microsoft-compatible.

If you have deleted a default slide layout, you can restore it by creating a new blank presentation, then copying and pasting the layout under the slide master of the deck to be repaired. You can also restore a default layout by running this VBA:

Sub RestoreLayout()
  With ActivePresentation.Slides
    .Add(.Count + 1, ppLayoutObject).Delete
  End With
End Sub

The example above restores a deleted Title and Content layout. Just change ppLayoutObject to the type you need from this list:

Layout Type VBA Parameter
Title Slide ppLayoutTitle
Title and Content ppLayoutObject
Section Header ppLayoutSectionHeader
Two Content ppLayoutTwoObjects
Comparison ppLayoutComparison
Title Only ppLayoutTitleOnly
Blank ppLayoutBlank
Content with Caption ppLayoutContentWithCaption
Picture with Caption ppLayoutPictureWithCaption
Title and Vertical Text ppLayoutVerticalText
Vertical Title and Text ppLayoutVerticalTitleAndText

Here are the recommendations that Microsoft should have published with the release of PowerPoint 2007: All new PowerPoint templates should include all default slide layouts and placeholders. That would have saved so much grief! Every file would be a Microsoft-compatible PowerPoint template or theme.

Please note, I am not suggesting that you restrict your design to only these layouts and placeholders. As long as you have the default layouts with the default placeholders, the rest of the master slide view can be filled with all kinds of special-purpose layouts with any number of placeholders. Just remember, whatever you create today must be supported in the future, if the slides are to remain paste-compatible. For more details, please see my article about best practices for reusing old (legacy) slides: Legacy Slides – Best Practices

I’m adding a plea for sanity on behalf of users everwhere: restraint in slide layout numbers is best for your client’s users. Too many layouts and they just don’t know which one to pick! Don’t confuse them more than they already are. Consider a limit of 25 layouts maximum.

We have years of expertise in this area and can assess your template for Microsoft compatibility, or create a template or theme for you that will work seamlessly with decks based on Microsoft templates. We’re here to help! Contact me at production@brandwares.com.

OOXML Hacking – Chart Template Colors

Chart templates solve the old problem of having to send out copy-and-paste samples of graphs. But they only display the first 6 of the chart template colors you designed.

Adding More Colors

The most common application of chart templates is to overcome the design limitation of having only a 6-color palette to work with. I wrote about this problem years ago: Office Charts: 6 Colors Maximum! – Best Practices. After a chart uses Accents 1 to 6, it starts recycling those same 6 colors with automatically generated darker and lighter variations. Banks and wealth management clients often need many more than 6 data series in their charts, but still want to have colors that are on-brand and designed.

To create a wider range of data series colors, create a chart with the maximum number of data series that the client requires. Our record is 25 colors! Then right-click on the chart edge and choose Save as Template. This captures the formatting of the sample that you’ve created.

Your template will work just fine on charts that have already been created. Select the chart, choose Change Chart Type (yes, even if it’s the right type already), click on the Templates icon, select the chart template and click on Apply. Easy peasy, job done!

Insert Chart Templates folder


The New Chart Problem

But this process breaks down if you try to create a new chart from that template. Choose Insert>Chart, click on Templates, and select the chart type. Then start inputting data. As soon as you get past the 6th color, Office starts using those damn Microsoft default darker and lighter variations instead of the colors you set! This is Authoritarian Helpfulness at its worst!

What You Designed
Chart template colors as designed
What Office Gives You
Chart template colors as created by Office

Yes, you can fix this. Reapply the template by choosing Change Chart Type>Templates and reselecting the template. The colors are corrected to the design specs. But you shouldn’t have to do this! And now that you’ve found this article, you don’t have to.


Understanding Chart Template Colors

Let me back up a bit, and explain how chart templates are structured. The top level of the XML consists of [Content_Types].xml, a _rels folder for documenting the relationships of XML parts and a chart folder holding the good bits.

Inside the chart folder, we find chart.xml, which holds most of the formatting that we created when we made the custom chart. Chart.xml contains definitions that contain the intended series color. The colors in chart.xml get set when you save the file as a chart template, and they get used when you apply the template to an existing table. But they are not used when you create a new chart.

Each series is numbered starting with 0, so this is the series for the 7th color. For the first six, the color is set to an accent color. Starting with the 7th, the color fills are in RGB/hexadecimal. Here’s a sample:

<c:ser>
  <c:idx val="6"/>
  <c:order val="6"/>
  <c:spPr xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart">
    <a:solidFill xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
      <a:srgbClr val="9AA4AF"/>
    </a:solidFill>
    <a:ln xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" w="19050">
      <a:noFill/>
    </a:ln>
    <a:effectLst xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"/>
  </c:spPr>
  <c:cat>
    <c:numRef/>
  </c:cat>
  <c:val>
    <c:numRef/>
  </c:val>
  <c:extLst>
    <c:ext uri="{C3380CC4-5D6E-409C-BE32-E72D297353CC}" xmlns:c16="http://schemas.microsoft.com/office/drawing/2014/chart">
      <c16:uniqueId val="{00000006-910C-4CE6-8943-18D1A951583A}"/>
    </c:ext>
  </c:extLst>
</c:ser>
 

In addition, there are subfolders for charts, media, theme, and _rels. The media folder only holds a BMP file that is used for thumbnail display in Office 2007 and 2010, but not in later versions. The _rels folder is for relationships of XML parts. The theme folder contains themeOverride1.xml. As the name suggests, this is a theme that overrides the theme of an Office file that hosts it. This allows you to use a chart template in any Office document while retaining the original design appearance. Finally, we have the charts folder, which has the XML part we’re looking for.

This folder contains 2 files: style1.xml, containing the formatting for all the chart parts and colors1.xml, with a list of default fill colors and transforms fo apply to those colors. Colors1.xml is the file that supplies the colors when a new chart is created from the template. Here’s what colors1.xml looks like:

<cs:colorStyle xmlns:cs="http://schemas.microsoft.com/office/drawing/2012/chartStyle" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" meth="cycle" id="10">
  <a:schemeClr val="accent1"/>
  <a:schemeClr val="accent2"/>
  <a:schemeClr val="accent3"/>
  <a:schemeClr val="accent4"/>
  <a:schemeClr val="accent5"/>
  <a:schemeClr val="accent6"/>
  <cs:variation/>
  <cs:variation>
    <a:lumMod val="60000"/>
  </cs:variation>
  <cs:variation>
    <a:lumMod val="80000"/>
    <a:lumOff val="20000"/>
  </cs:variation>
  <cs:variation>
    <a:lumMod val="80000"/>
  </cs:variation>
  <cs:variation>
    <a:lumMod val="60000"/>
    <a:lumOff val="40000"/>
  </cs:variation>
  <cs:variation>
    <a:lumMod val="50000"/>
  </cs:variation>
  <cs:variation>
    <a:lumMod val="70000"/>
    <a:lumOff val="30000"/>
  </cs:variation>
  <cs:variation>
    <a:lumMod val="70000"/>
  </cs:variation>
  <cs:variation>
    <a:lumMod val="50000"/>
    <a:lumOff val="50000"/>
  </cs:variation>
</cs:colorStyle>

On a newly inserted chart, an Office program will use the 6 colors in turn. Then it will cycle through them again, applying the a:lumMod val=”60000″ transform. LumMod modifies the luminance, turning each accent color to a dark version. The chart will follow this pattern instead of using the colors you designed for the extra data series. If you reapply the chart type to the chart, then it will update with your designed colors from chart.xml


Fixing Chart Template Colors

My first step was to read the Microsoft specs for cs:colorStyle. Under section 2.8.3.2 CT_ColorStyle, it reads: “The total set of colors is all contained colors repeated each time with each variation applied. A color style can contain 6 colors and 7 variations. This yields a total of 42 colors with the first 6 having the first variation applied, the second 6 having the second variation applied and so on.” Not promising, we really need more than 6 colors here.

After many fruitless experiments, I decided to see if I could add extra colors anyway:

<cs:colorStyle xmlns:cs="http://schemas.microsoft.com/office/drawing/2012/chartStyle" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" meth="cycle" id="10">
  <a:schemeClr val="accent1"/>
  <a:schemeClr val="accent2"/>
  <a:schemeClr val="accent3"/>
  <a:schemeClr val="accent4"/>
  <a:schemeClr val="accent5"/>
  <a:schemeClr val="accent6"/>
  <a:srgbClr val="9AA4AF"/>
  <a:srgbClr val="C2C6C9"/>
  <a:srgbClr val="B76646"/>
  <a:srgbClr val="E2C2B5"/>

To my astonishment, it worked! I could create a new chart and insert 10 dataseries with each displaying the designed color. No need to reapply the template! Who would ever have dreamt that Microsoft documentation has a mistake in it! ;-D

The takeaway is that to create a many-colored chart template that works as expected under all circumstances, you need to set the extra color values manually in colors1.xml.

Word Table Styles – Best Practices

Unlike PowerPoint, Microsoft Word has a utility to create custom Word table styles. You might think this makes life a lot easier, but you would be wrong. The Word utility has quirks and bugs, and Word tables don’t work the same way as PowerPoint’s. Using the Table Style dialog is not intuitive. To get a Word table style to work exactly to the way it should, you may have to hack the OOXML.

To start, let’s clarify that a table style is one of 4 styles that you can create in Word. The others are paragraph, character and list styles. A well-constructed table style does not need to have paragraph styles applied to it later. That’s because it already contains paragraph styles, though these don’t have the conventional names that you’re familiar with. Here’s how to get the best possible results.


Start with a similar table style

The first step in creating a custom table style is to insert a table, so the Table Design tab appears. By default, a new table will use the Table Grid style, which is very plain. If your final table style requires design options like a distinctive first column or a total Row, Table Grid is a poor place to start. It doesn’t include any of those options, and adding them back in is difficult. Switch the style to a Microsoft default that already has similar features.

Next, expand the table style gallery dropdown again and select New Table Style at the bottom. This ensures that your table style will appear in a new Custom row right at the top of the styles gallery. By contrast, starting with Modify Table Style lumps your style in with all the Microsoft defaults.

New Table Style in custom Row


Base the new style on the chosen one

When you choose Table Design>Table Styles>New Table Style, Word sets the Style based on dropdown to Table Normal, not the style you chose. If you originally chose Grid Table 5 Dark, then set Style based on to the Grid Table 5 Dark. (Current versions of Word for Mac have a display bug whereby choosing a different table style does not update the preview in the dialog. Choose the style, OK out, then choose Modify Table Style to see a corrected preview.)


Start with Whole table

Start with the Whole table choice in the Apply formatting to dropdown. This is the default cell formatting that will appear when no other Table Style Options are applied. The formatting controls are condensed, here’s a breakdown of which control does what:

Table Style Formatting Controls

If the formatting control you need doesn’t appear in the dialog, use the Format dropdown in the lower left corner to access more of them.


Move on to Header row

After you’ve set the default cell style, choose Header row from the Apply formatting to dropdown. This is where the dialog gets buggy. Many of the controls will retain their value from whatever table part you were previously editing! The controls will sometimes, but not always, display the values used in the new table part you have just selected (in this case, Header row)! So it’s up to you to keep track of what the correct values are for the table part you’re formatting, and apply each in turn.


Format each table part in order

Because of the dialog display inconsistencies, it’s easiest to format each table part in the order they show in the Apply formatting to dropdown.

As you format each table part, Word creates, in effect, a separate paragraph style for each table part. But you don’t apply these styles by choosing a style name. Instead, you check a box in the Table Style Options group of the Table Design tab. Checking the Header Row option automatically applies the Header Row style to the top row of the selected table. When you’re creating a table style for a client, this means many design options can be included in one table style, and you don’t have to include elaborate instructions about which style to manually apply to which table part.


What about the corner cells?

The last 4 items on the Apply formatting to dropdown are to format the top left, top right, bottom left and bottom right corner cells. But there is no Table Style Option to turn these on and off directly. The way Word handles this is that if both the Header Row and First Column options are checked, then the formatting for the top left corner cell is turned on. This formatting can be different from either the header row or the first column. Header Row plus Last Column will turn on the upper right cell. You get the idea.

FWIW, PowerPoint table styles can also have corner cell formatting and the cell formatting is applied in the same way, by using pairs of style options.

Header Row + First Column = Top Left Cell


Word Table Style Quirks

There are some oddities about Word table styles, and a few bugs. One oddity is that table text is based on the Normal style in relationship to Word’s Default Text settings. If Normal has been set to any color other than Automatic, applying different text colors to different table parts will have no effect. The text will remain the color set for Normal. You then have to apply new paragraph styles to the table parts after creating the table.

Another weird result of the dependency on Normal is that Word expects to have the default line spacing for your version of Word. As I write, Word 365’s default Normal style has a Line spacing of Multiple at 1.08 with Space After of 8 points. In a table style, this gets automatically reinterpreted as Single with 0 before and after. Centered vertical spacing then works as expected. If you change the Normal line spacing to a larger or smaller value, text that is nominally vertically centered will actually sit higher or lower in the cell. If you add 12pt after, the table text will jump from being vertically centered to having 12 pt after, a huge difference. Microsoft doesn’t publish any of this information. Surprise!

This is one of the reasons why Word experts recommend that Normal style should stay as is and not be actually used in a document unless the default formatting matches the needs of the design. Better to format all text as Body Text style and give that style the custom color and line spacing.

But what if you’re given a template that already has a non-standard Normal, and the client asks for a table style? All is not lost. Table styles can still work as designed if you are using Word for Windows (sorry, Mac people). The trick here is to set the document text defaults to the same values as the revised Normal style. (Thanks to MVP Stefan Blom for this tip.) Here’s how to do this:

  1. With the document or template open in Word, click on the Styles pane dialog opener below the Quick Styles gallery, or press Alt + Ctrl + Shift + s at the same time. The Style pane opens.
  2. Click on the Manage Style button at the bottom.
  3. Select the Set Defaults tab.
  4. Set the defaults to the same values as Normal style: same font, size, color and paragraph settings. OK out.

You’ll know you got it right when you insert a table in the new style and it automatically has the correct styling for header row, first column and the other table style options. It is no longer necessary to apply text styles to the table, you can simply turn the Table Design>Table Style Options on and off to affect the related table area.


Word Table Style Bugs

Lousy User Interface Design

In the table style dialog, color dropdowns remain set at the color last chosen, even if that was for a different table part. The dropdown should update to the color currently in use for the table part that has been selected. This is just common-sense UI design.

The interface for setting border styles is pretty bad. It’s almost impossible to set one color for vertical borders and a different one for horizontal borders. All borders switch to the last selected color. But we can fix this with an OOXML hack (see below).

Defective Override Capabilities

Subsequent parts can’t always override the XML of earlier parts. As an example, set the Whole table to have internal vertical rules. Then set the first column to have no rule on the right. This should make the vertical rule separating the first column from the second column disappear, but it doesn’t. The rule has to be manually removed after the table is created.

Non-Functional OOXML Tags

The Paragraph Properties (w:pPr) element for each table part has a pStyle attribute that is supposed to set the paragraph style for that part. It does nothing. As mentioned above, the style is always derived from Normal style.


Format the Word table style options in order.

Word Table Styles: Order of Elements

Start by formatting the Whole table section with the defaults for cell in the middle of the preview. Most of the time, this will include the font size and color, and the table background color and any rules that are to appear if banded rows are turned off. If you can’t get the formatting you need from the few controls on the dialog, click on the Format dropdown to find detailed access to Table Properties, Borders and Shading, Banding, Font and Paragraph attributes. Under Windows, you’ll also see a Text Effects choice, which is of dubious value in a table.

Word Table Styles Formatting Options

Then move on to Header Row formatting, the next item on the Apply formatting to dropdown. Format each item on that dropdown until you have set all the properties you need. After you get all formatting set, apply the custom style to the sample table you created at the beginning. Then use Modify Table Style for any tweaks required.


Word Table Style Hacks

Default style formatting is hardcoded in Word. So the styles that get stored in a Word file are only styles that have been modified or newly created in the document. All of the style exceptions and new style definitions are stored in the word/styles.xml part. Here’s the OOXML for a full table style. First, the section that formats the whole table. Pr stands for Property. tbl is Table, tc is Table Cell, p is Paragraph and r is Run (any length of text less that a paragraph).

<w:style w:type="table" w:customStyle="1" w:styleId="SampleTableStyle">
  <w:name w:val="Sample Table Style"/>
  <w:basedOn w:val="GridTable3"/>
  <w:uiPriority w:val="99"/>
  <w:rsid w:val="00264468"/>
  <w:rPr>
    <w:color w:val="282828" w:themeColor="text1"/>
    <w:sz w:val="18"/>
    <w:szCs w:val="20"/>
    <w:lang w:val="en-US"/>
  </w:rPr>
  <w:tblPr>
    <w:tblBorders>
      <w:top w:val="none" w:sz="0" w:space="0" w:color="auto"/>
      <w:left w:val="none" w:sz="0" w:space="0" w:color="auto"/>
      <w:bottom w:val="none" w:sz="0" w:space="0" w:color="auto"/>
      <w:right w:val="none" w:sz="0" w:space="0" w:color="auto"/>
      <w:insideH w:val="single" w:sz="6" w:space="0" w:color="BFBFBF"/>
      <w:insideV w:val="single" w:sz="6" w:space="0" w:color="282828"/>
    </w:tblBorders>
  </w:tblPr>
  <w:tcPr>
    <w:vAlign w:val="center"/>
  </w:tcPr>

(Above) The w:rPr section sets the default text while w:tblPr sets the borders. This table is transparent when all design options are turned off, so there is no fill. Note the entries for w:insideH and w:insideV. I had to hack this XML to get different colors for the inside horizontal and inside vertical borders.

(Below) Next is the formatting for the header row. w:rPr sets the text as bold and white, while w:tcPr sets the cell borders to nothing and the fill to Accent 2.

  <w:tblStylePr w:type="firstRow">
    <w:pPr>
      <w:jc w:val="left"/>
    </w:pPr>
    <w:rPr>
      <w:b/>
      <w:color w:val="FFFFFF" w:themeColor="background1"/>
    </w:rPr>
    <w:tblPr/>
    <w:tcPr>
      <w:tcBorders>
        <w:top w:val="nil"/>
        <w:left w:val="nil"/>
        <w:bottom w:val="nil"/>
        <w:right w:val="nil"/>
        <w:insideH w:val="nil"/>
        <w:insideV w:val="nil"/>
      </w:tcBorders>
      <w:shd w:val="clear" w:color="auto" w:fill="346577" w:themeFill="accent2"/>
    </w:tcPr>
  </w:tblStylePr>
  <w:tblStylePr w:type="lastRow">
    <w:pPr>
      <w:jc w:val="left"/>
    </w:pPr>
    <w:rPr>
      <w:b/>
    </w:rPr>
    <w:tblPr/>
    <w:tcPr>
      <w:tcBorders>
        <w:left w:val="nil"/>
        <w:bottom w:val="nil"/>
        <w:right w:val="nil"/>
        <w:insideH w:val="nil"/>
        <w:insideV w:val="nil"/>
      </w:tcBorders>
      <w:shd w:val="clear" w:color="auto" w:fill="auto"/>
    </w:tcPr>
  </w:tblStylePr>

(Above) The previous section formats the Total Row, removing the borders. There’s another hack here: the w:shd illustrates how to set the fill as No Color, with both w:color and w:fill set to auto.


(Below) Next up is the First Column formatting. w:pPr sets the text flush right, w:rPr makes it bold and w:tcPr removes the borders and keeps the fill No Color. Oddly, while w:insideH successfully overrides the internal horizontal rules set in the Whole Table section, neither w:right nor w:insideV are able to remove the internal vertical rule to the right of the column. This works as expected in a PowerPoint table style, but is broken in Word.

  <w:tblStylePr w:type="firstCol">
    <w:pPr>
      <w:jc w:val="right"/>
    </w:pPr>
    <w:rPr>
      <w:b/>
    </w:rPr>
    <w:tblPr/>
    <w:tcPr>
      <w:tcBorders>
        <w:top w:val="nil"/>
        <w:left w:val="nil"/>
        <w:bottom w:val="nil"/>
        <w:right w:val="nil"/>
        <w:insideH w:val="nil"/>
        <w:insideV w:val="nil"/>
      </w:tcBorders>
      <w:shd w:val="clear" w:color="auto" w:fill="auto"/>
    </w:tcPr>
  </w:tblStylePr>
  <w:tblStylePr w:type="lastCol">
    <w:rPr>
      <w:b/>
    </w:rPr>
    <w:tblPr/>
    <w:tcPr>
      <w:tcBorders>
        <w:top w:val="nil"/>
        <w:left w:val="nil"/>
        <w:bottom w:val="nil"/>
        <w:right w:val="nil"/>
        <w:insideH w:val="nil"/>
        <w:insideV w:val="nil"/>
      </w:tcBorders>
      <w:shd w:val="clear" w:color="auto" w:fill="auto"/>
    </w:tcPr>
  </w:tblStylePr>

(Above) The right-most table column is formatted with no borders and no fill.

(Below) If your design includes banded columns, the table style will include a section like this. There is just a definition for odd columns: even columns would be formatted with the defaults from the Whole Table section. If the First Column option is turned off, odd columns start at the left-most column. If First Column is turned on, all columns shift and the column just to the right of the first column takes on odd column formatting.

  <w:tblStylePr w:type="band1Vert">
    <w:tblPr/>
    <w:tcPr>
      <w:shd w:val="clear" w:color="auto" w:fill="D4D4D4" w:themeFill="text1" w:themeFillTint="33"/>
    </w:tcPr>
  </w:tblStylePr>

  <w:tblStylePr w:type="band1Horz">
    <w:tblPr/>
    <w:tcPr>
      <w:tcBorders>
        <w:left w:val="nil"/>
        <w:right w:val="nil"/>
        <w:insideH w:val="nil"/>
        <w:insideV w:val="single" w:sz="6" w:space="0" w:color="282828" w:themeColor="text1"/>
      </w:tcBorders>
      <w:shd w:val="clear" w:color="auto" w:fill="F2F2F2" w:themeFill="background1" w:themeFillShade="F2"/>
    </w:tcPr>
  </w:tblStylePr>

(Above) Odd Row and (Below) Even Row formatting.

  <w:tblStylePr w:type="band2Horz">
    <w:tblPr/>
    <w:tcPr>
      <w:tcBorders>
        <w:left w:val="nil"/>
        <w:right w:val="nil"/>
        <w:insideH w:val="nil"/>
        <w:insideV w:val="single" w:sz="6" w:space="0" w:color="282828" w:themeColor="text1"/>
      </w:tcBorders>
      <w:shd w:val="clear" w:color="auto" w:fill="D9D9D9" w:themeFill="background1" w:themeFillShade="D9"/>
    </w:tcPr>
  </w:tblStylePr>

(Below) Formatting for the 4 corner cells. These are only activated when both options that affect the cell are turned on. As an example, if the table has both a Header Row and a First Column, then the nwCell formatting is turned on. In the formatting for nwCell below, the text becomes flush right when both options are used.

  <w:tblStylePr w:type="neCell">
    <w:pPr>
      <w:wordWrap/>
      <w:jc w:val="left"/>
    </w:pPr>
    <w:tblPr/>
    <w:tcPr>
      <w:tcBorders>
        <w:bottom w:val="nil"/>
      </w:tcBorders>
    </w:tcPr>
  </w:tblStylePr>
  <w:tblStylePr w:type="nwCell">
    <w:pPr>
      <w:wordWrap/>
      <w:jc w:val="right"/>
    </w:pPr>
    <w:tblPr/>
    <w:tcPr>
      <w:tcBorders>
        <w:bottom w:val="nil"/>
      </w:tcBorders>
    </w:tcPr>
  </w:tblStylePr>
  <w:tblStylePr w:type="seCell">
    <w:tblPr/>
    <w:tcPr>
      <w:tcBorders>
        <w:top w:val="nil"/>
      </w:tcBorders>
      <w:shd w:val="clear" w:color="auto" w:fill="auto"/>
    </w:tcPr>
  </w:tblStylePr>
  <w:tblStylePr w:type="swCell">
    <w:tblPr/>
    <w:tcPr>
      <w:tcBorders>
        <w:top w:val="nil"/>
      </w:tcBorders>
      <w:shd w:val="clear" w:color="auto" w:fill="auto"/>
    </w:tcPr>
  </w:tblStylePr>
</w:style>

If you base your Word table styles on a table other than Table Normal, that table style will be included in styles.xml. If that table style includes formatting that you don’t want to included in your table style, then delete the section in the style it’s based on. As an example, this style was based on Grid Table 3, which includes a last column and a total row. To remove all last column and total row formatting from your style, delete the corresponding XML sections in both your custom style and in the style on which it’s based. You’ll know when you’re succesful when turning the Last Column and Total Row Design Options on and off in Word has no visual effect on a sample table.

Too complicated? Shoot me a message and we’ll create custom Word table styles for your document or template.

Search Engine Expertise – Best Practices

I don’t actually know much, but I have search engine expertise. I’ve answered thousands of question for users on various online fora, and I’m constantly amazed by the vast number of queries that could be answered by a simple Google search. My takeaway is that people just don’t know how to use search engines to their best advantage.

Search Engine Expertise – The Mandatory Word

When a search must include a particular word or phrase, put it in double quotes, if you’re using Google. For Bing and most other engines, add a plus sign before. Here’s a search that must include Word in the results:

Google - "Word" VBA typestyle
Bing and others - +Word VBA typestyle

Search Engine Expertise – The Excluded Word

You’re looking for Word VBA information, but you get pages of useless Excel stuff. For all search engines, add a minus sign before the word you don’t want:

VBA -Excel tables

Search Engine Expertise – The Special Site

You know that you saw an answer on a particular web site, but it was a long time ago and you can’t remember where. Type your search terms, then type site:, then the site URL. No space between site: and the URL:

"edit mode of header/footer" site:answers.microsoft.com

Searching Phrases Instead of Words

Put the phrase between double quotes. The following shows results about the top of the page that don’t refer to the header and footer:

Word top part of page -"header and footer"

A Practical Example

Do you use Office for Mac? It’s hard to find relevant information, since the Mac version is still quite different from Office for Windows. Just add “for Mac” to your search terms and watch as hundreds of pages of useless Windows pages disappear. This can save you hours of time!

Using just these 4 tips, you’ll find relevant information much more quickly. You may have even more specific requirements. Check out the Advanced Search page for your preferred engine, you may find some techniques that will make your day more efficient:

Google Advanced Search

Bing Advanced Search

Edit OOXML with VBA – Cool Code

For Office users, the closest thing to a “programming language of the people” is VBA. It’s not too hard to get started, there are gobs of help information from a good search, and the results are immediate. But VBA’s abilities haven’t expanded as its environment has changed. This has become abundantly clear with current versions of Office, where task panes and the Windows-version Backstage haven’t been included in the VBA object model. Many want to edit OOXML with VBA, but Microsoft prefers to shuffle you off to the Open XML SDK programmed with C# to do that job.

Fortunately, we’re on the case at Brandwares. We collaborated with programmer Jan Karel Pieterse to develop a PowerPoint version of his macro set that edits Excel OOXML. We’re making this freely available as a download so you can get the benefit of this.

Let me apologize to my macOS readers. I really try to provide solutions that work cross-platform, but this macro set relies on Windows system calls.

I’ll be honest, this isn’t the most elegant OOXML editing solution. The macro set unzips the OOXML to its component files, gives you the opportunity to edit the XML using VBA string manipulation, then rezips the OOXML to a usable PowerPoint file. The unzip/rezip operations are fairly slow, especially with large files. It’s not something you can use in a real-time editing situation.

One of Brandwares’s specialties is converting legacy presentations to new themes/templates. Often, there are OOXML mismatches that make reused slides retain artifacts or formatting from the old decks. We solve these issues with macro convertors that take a folder full of old decks and transform them into new presentations with new branding. This macro set is great for that.


Edit OOXML with VBA: a Peek Under the Hood

THe file contains 3 VBA modules and 1 class module. Module modConvert is the only one you need to modify. In it, Sub MainVBAOperations does the actual work of opening files, saving as a work file, calling the XML process, saving the modified file and deleting the work file. This is also where you would do any additional VBA processing. As one example, after you modify the XML of a slide master or layout, you have to reset the slide based on it to display the changes. MainVBAOperations is where you would do this.

The other Sub is ProcessXML. Here’s where you unzip the file being modified, open different XML parts for find and replace processes, followed by a rezip of all files back to a working file. The sample code in this module shows a typical revision to the idx numbers of placeholders, a common requirement of legacy presentation conversions and one that can’t be done with the PowerPoint interface.

The module modDisplay, by Shyam Pillai, provides the PowerPoint equivalent of the Application.Screenupdating command that exists in Word VBA. Useful to prevent the screen flashing and jumping as files are processed, it also helps speed code execution. modUNC by Randy Birch, assists with file management.

Jan Karel Pieterse wrote the class module clsEditOpenXML that does the heavy lifting of unzipping and rezipping the document to be modified and reading and writing the XML.

As noted in the code, You are free to use this code within your own applications, add-ins, documents etc but you are expressly forbidden from selling or otherwise distributing this source code without prior consent. This includes both posting free demo projects made from this code as well as reproducing the code in text or html format.


Converting Legacy Presentations

We use often use this macro set to update old (legacy) presentations with a new design. Successful updating requires meeting 5 criteria, please read this article for more details: Legacy Slides – Best Practices. As noted on that page, the 5th requirement is that placeholder idx numbers in the OOXML must match on the old and new layouts. There’s nothing in PowerPoint’s interface that allows you to set idx number, but this macro set allows you to do just that. The pre- and post-processing sections of the macros allow you to set the the other 4 parameters for each slide layout. Click here to download it.

The following advice is particular to presentation conversion. It’s routine that slide masters and layouts will be changed in that process. Then, to apply those changes to the actual slides in a presentation, the slides must be reset, as if you pressed the Home>Reset button in a presentation. Resetting slides wipes out character-based formatting. If a user has applied bold or italic or an underline to particular text, that all will disappear. It’s important to notify your client of this. To make an exact update would require a painstaking construction of a multi-dimensional array for each placeholder on each slide that would record all character-based formatting, then restore it after the update, for which you would have to charge many times as much as for the basic conversion work.

Brandwares is a world leader in presentation updating and conversion. We’re available for presentation assessments, to identify potential problems. We have multiple techniques for seamless re-use of legacy presentations. Contact us when you’re redesigning to ensure your new template will reuse your old slides without a hiccup.

Multiple Slide Masters: Beware! – Best Practices

One of my areas of expertise is to do presentation assessments for designers, finding any potential problems in their work before sending their file to their client. Something I see fairly often is multiple slide masters in a template or theme, where they are used as an organizational tool. Typically, one master will be for title slides, another for section headers, and so on. This is a poor practice, but it goes on because designers never have to actually use the files they create. If they did, the problem would soon become evident. Here’s a typical example:

Three Slide Masters


Multiple Slide Masters – How They Work

If I asked you “How does PowerPoint know which slide master to use when there is more than one?”, what would your answer be?

Well, I’ve done the research, so I can let you know. When you paste slides into a presentation, PowerPoint looks at the slide immediately preceding the paste position and uses the slide master for that slide. If there are no slides in the presentation, then PowerPoint uses the first slide master. This has major consequences for the format of the pasted slides. If the slide master of the preceding slide has only title layouts, only the pasted title slides will find their rightful layout. All the rest of the slides will bring their old layout with them. So now the slide master for titles has a whole bunch of non-title layouts. Oops. So much for your organizational scheme. Following are the original slides, followed by what they look like when pasted after slides based on different masters:

4 slides based on 3 slide masters
4 slides from 3 masters
Pasted after slide based on first master
Pasted after first slide
Pasted after slide based on second master
Pasted after second slide
Pasted after slide based on third master
Pasted after third slide

If the pasted slides are from legacy presentations, where the intention was to update them to the new look, you get a total fail. Not only do they not update, they’ve ruined the new deck with added old layouts. The next time the user adds a new slide and tries to find a layout in that slide master, they get a psychedelic soup of designs.

But wait! It gets worse! For some bizarre reason, designers have a bad habit of deleting all the placeholders on the slide master, then building the design in the layouts. Ouch! The placeholders on the slide master are parents to the child placeholders on the layouts. They are the source for font and paragraph formatting in layout placeholders, as well as the default placeholder positioning. When you paste slides so they use that blank slide master, formatting goes haywire. The slide layouts that get imported with the pasted slide have no source to tell them how to display content. PowerPoint makes a guess and always guesses wrong. Bold text becomes regular, font sizes changes, pictures disappear. It’s a nightmare, and one that designers just don’t understand, can’t explain to their clients, and have no idea how to fix.


A Better Approach

Just use a single slide master. In 99% of presentations, one slide master is all you need. That slide master should be formatted as closely as possible to look like a typical content slide. Then for layouts that have different formatting, right-click on the layout background and choose Format background. In the Format Background task pane, check the option for Hide background graphics. Then place the alternate graphics on that layout.

About the placeholders: keep them! Deleting the default placeholders does nothing helpful and can cause problems. If someone pastes a slide with a footer and your layout doesn’t have a footer placeholder, the footer text will reposition itself, often at the very left edge of the slide, because the content has been orphaned. If your design doesn’t include a footer, move the placeholder off the bottom of the layout! This makes a pasted footer simply disappear instead of looking goofy.


Multiple Slide Masters – When and How to Use Them

So far, there are only 2 uses I’ve found a genuine need for multiple slide masters. One is when a presentation requires multiple color themes. Some organizations have divisions that use code colors: a key color that is used only in that group. This situation was easier in PowerPoint 2003 and earlier, because you could easily apply different color schemes to groups of slides. Modern versions have only 1 color theme per slide master. If you change the color theme, all the slides change. Here’s how to handle that situation:

Under the slide master, create the complete set of layouts needed for the presentation. Set the code color in Accent 1 if it’s a predominant element of the client branding. If it’s a subtle design change, Accent 6 is better. Get the client to sign off, so the design is not going to need a lot of future revisions. Then copy and paste the slide master for each code color required. Finally, revise the color theme for each slide master, changing only the accent color. Following this method, every slide master has every layout. The worst that can happen is someone pastes in the wrong place and the code color is off. Easily fixed.

The other time you need multiple masters when a client has rolled out a new template, then realizes they need to handle legacy slides. Then you create a second slide master with layouts that match the new look but have a layout structure that is compatible with the old decks. At the beginning of the deck create 2 sample slides, one based on the new slide master and another based on the legacy slide master. Place a notice to the user just off the edge of the slide master for the first slide: “New slides only! Don’t paste old slides!” and on the second “Paste old slides here! No new ones!”. Then users are less likely to paste slides in the wrong spot and get weird results.

OOXML Hacking: Replacing Fonts and Languages in PowerPoint

Replacing odd fonts and errant languages in PowerPoint is not something that always works well in the program. Problems with replacing double-byte fonts for Asian languages have been documented on other pages, but designers also have problems replacing Mac-only formats like AAT (Apple Advanced Typography) fonts.

There’s a similar problem with languages. While language tags are scattered all over in XML, you can only reach some of them with PowerPoint’s built-in Review>Language>Set Proofing Language (Windows) or Tools>Language (macOS) command. When files are moved between computers, it’s very easy for the file to have a mix of language tags.

In Windows, there are some free macros available to make replacing languages easier in PowerPoint, but there’s no equivalent for Macs. So here’s my go-to method to fix both problems with not much more than a good text editor, like NotePad++ in Windows and BBEdit on Mac. If you’re new to this site, please read my introductory articles OOXML Hacking: An Introduction and, if you’re on a Mac, OOXML Hacking: Editing in macOS.

Referring to the macOS article, a patient Mac user can use BBEdit 11 or better to open a presentation, select each file in turn and get the job done. But your time will be better spent by creating a network or USB disk that doesn’t create .DS_Store files. It’s a little time-consuming the first time, but if you’re someone who creates PowerPoint files on a regular basis, you’ll soon recover that time. The nice thing about this technique is that it always works, 100% of the time, even with double-byte fonts.


Replacing Fonts in PowerPoint

Unwanted fonts can be introduced when you’re doing design experiments, collaborating with clients, or when you convert a KeyNote presentation to PowerPoint. In all these cases, you may end up with fonts you cannot remove, or even with a deck you cannot save. Start by making a list of all fonts that need to be eliminated. You can get the names by choosing Home>Replace>Replace Fonts (Windows) or Edit>Find>Replace Fonts (macOS menu). Then expand the PowerPoint file to XML parts.

Now fire up your text editor. Both BBEdit and NotePad++ include utilities to find and replace in files. With both, you point the find at a folder full of expanded XML files from your presentation. In the Find field, look for typeface=”Font Name”, where the font name is the name listed in Home>Replace>Replace Fonts (Windows) or Edit>Find>Replace Fonts (macOS menu). The Replace field should also be typeface=”Font Name”, but here the font name is the font to match the rest of the deck. Executing the Find and Replace should display a list of files where changes were made. Both programs automatically save the changed files, so all you have to do is close the text editor and rezip the XML back to a presentation.

Windows users can take a shortcut with this process. PowerPoint for Windows has a save format called PowerPoint XML Presentation (*.xml). This saves the entire presentation as one big XML file. Open that file in plain old NotePad, choose Edit>Replace and do the same replacement as above. No fancy text editor needed! Then open the XML file in PowerPoint and save to a normal presentation format for your client.


Replacing Languages in PowerPoint

PowerPoint puts language tags all over the place. Here’s a random sample showing one paragraph with one word that contains 2 different language tags!:

<a:p>
  <a:r>
    <a:rPr lang="en-US" dirty="0">
      <a:latin typeface="Arial Black" panose="020B0A04020102020204" pitchFamily="34" charset="0"/>
    </a:rPr>
    <a:t>Test</a:t>
  </a:r>
  <a:endParaRPr lang="en-CA" dirty="0">
    <a:latin typeface="Arial Black" panose="020B0A04020102020204" pitchFamily="34" charset="0"/>
  </a:endParaRPr>
</a:p>

The technique is nearly identical to font replacement, you just search on a different tag. In the example above, we would find lang=”en-CA” and replace it with lang=”en-US” to create a uniform U.S. English presentation. Here at Brandwares, we do a lot of international work, so files can have language tags from all over. A standard part of file finalization is replacing language tags with the target language for the client.

When you’re working with OOXML files, multifile find and replace is a very useful technique to solve all kinds of problems. As another example, here’s my article on fixing broken color themes with similar techniques: OOXML Hacking: Repairing Color Themes. Mastering multifile find and replace can save you hours over manual repairs to PowerPoint files.

Is your problem more complex? You just can’t get the result you want with find and replace? That’s why we’re here, to help you get your work done faster! Shoot me an email at production@brandwares.com, I’ll get you going in a jiffy.