OOXML Hacking: Custom Colors

In my last post, I looked at adding extra color themes to PowerPoint masters. But any color theme can only hold a maximum of 10 colors (not counting the hyperlink colors, which are not available in the color picker). Sometimes designers create an expanded palette and they don't like to be told "Sorry, we can only fit 10, we'll have to throw out the rest.", especially after the design has already been approved by the client.

Fortunately, most versions of Office programs beginning with 2007 have a hidden capacity to display up to 50 custom colors. These form a new row below the theme colors and above the stock Microsoft row. Custom colors are not supported in PowerPoint 2008 or 2011 for OS X. While these versions will open a file with custom colors, the colors do not get added to the color picker. Here's what the color picker in every other variety of Word or PowerPoint looks like after adding custom colors:

Custom Colors in Office
Custom Colors in PowerPoint

OOXML Basics

If you're new to XML hacking, be sure to read my Introduction to the subject first. If you're editing on a Mac, there are some other considerations covered in this article. I should also clarify: a Color Theme or a Font Theme are only sub-parts of a Theme as saved by PowerPoint. A PowerPoint Theme file contains the entire presentation, including masters, layouts, and full theme files. It's this full theme file that we need to edit. Custom Colors never appear in a Color Theme file.

As with the extra color themes we looked at last time, custom colors are added to the XML theme files found in ppt>theme. I mentioned in the last article, presentations almost always include a default Office theme as a fallback and this theme is always last in the list. So in a presentation with 1 color theme, there will be a theme1.xml and a theme2.xml inside the theme folder. Ignore theme2.xml and customize only theme1.xml.


Setting Custom Colors

Custom colors are the last category in a theme file, so it's easy to find. As before, we expand the PowerPoint file (really a zip archive with a different file ending), open ppt/theme, open theme1.xml in a text editor and reflow the text to be humanly readable. Then scroll all the way down to the end. An unmodified file will only display the <a:extraClrSchemeLst/> stub to which you add custom color themes. To add custom colors, we add a new branch to the tree. Between <a:extraClrSchemeLst/> and </a:theme>, we type a new entry: <a:custClrLst>. This is followed by our custom color definitions and the closing tag </a:custClrLst>. Here's what a list of custom colors as seen in the screenshot above would look like in XML:
Custom Color List

A nice feature here is that, unlike color themes, you can actually supply a name for the color. This is followed a hexadecimal RGB color value, as used in web design. This list has only 8 colors, but there is room for up to 50 in the custom color area. If you read the last article about color themes, you'll soon realize that each theme file can have a different set of custom colors that goes with it as well. The combination of themes and custom colors gives you 18 colors per theme to play with, almost enough for the most color-crazed designer.

Custom colors can be added to the theme1.xml file in Word and Excel using exactly the same syntax. The colors appear in the color picker as expected in Word but are partially ignored in Excel. In Excel, custom colors display for almost all objects on the Insert tab: Text Boxes, Shapes, SmartArt, Charts, WordArt, etc. But if you're seeking to format worksheet text, cell fills or borders, custom colors do not show. (Thanks to reader Kaz for pointing this out.)


Custom Colors in Columns

By default, the colors appear in 5 rows of 10 colors each. Some designers prefer to display the colors in columns instead of rows. To work around this, add custom colors to form the top row of your columns. Then complete the row of 10 with dummy colors that have a value of FFFFFF and blank as a name:

<a:custClrLst>
  <a:custClr name="Grey">
    <a:srgbClr val="797472"/>
  </a:custClr>
  <a:custClr name="Very Light Grey">
    <a:srgbClr val="F9F8F5"/>
  </a:custClr>
  <a:custClr name="Red">
    <a:srgbClr val="E33126"/>
  </a:custClr>
  <a:custClr name="Light Grey">
    <a:srgbClr val="D0CECE"/>
  </a:custClr>
  <a:custClr name="Dark Red">
    <a:srgbClr val="A01B14"/>
  </a:custClr>
  <a:custClr name="Light Red">
    <a:srgbClr val="F29A96"/>
  </a:custClr>
  <a:custClr name="blank">
    <a:srgbClr val="FFFFFF"/>
  </a:custClr>
  <a:custClr name="blank">
    <a:srgbClr val="FFFFFF"/>
  </a:custClr>
  <a:custClr name="blank">
    <a:srgbClr val="FFFFFF"/>
  </a:custClr>
  <a:custClr name="blank">
    <a:srgbClr val="FFFFFF"/>
  </a:custClr>
</a:custClrLst>

Here's the effect in the program interface:

Custom Colors - Dummy Blank Colors

Another limitation is that if you save a presentation as a Theme (*.thmx) file, custom colors in the presentation don't get added to the Theme file. You'll have edit a saved Theme file to add the custom colors to it, then they can be applied to another file. Or you can save the original presentation as a Presentation (*.pptx, *.pptm) or Template (*.potx, *.potm) to preserve the Custom Colors.

By extension, this also means that to add custom colors to Word by applying a PowerPoint Theme file, you must edit the Theme file to add the custom colors. Or course, you can hack the Word document or template to get them. The file name in Word will be the same: theme1.xml, but it is to be found in the word/themes folder instead of ppt/themes. As with PowerPoint, custom colors are added to the very end of the theme.xml part.

Unlike theme colors, custom colors are not automatically applied to charts. Automatic chart coloring in PowerPoint, Excel and Word is limited to 6 settable colors (see this post for chart coloring details). After that, the host program starts generating automatic variants based on the theme. However, for the detail-oriented among us, manual recoloring of data series with custom colors is very convenient and miles above the previous technique, inputting RGB values from text.

We're here to do this for you, if you prefer! Please contact me at production@brandwares.com. Next time, I'll tackle formatting custom table formats in XML. This is a complex subject, so it will take at least 2 posts. Stay tuned!

9:35 pm

72 thoughts on “OOXML Hacking: Custom Colors

  1. Thanks for this -- good stuff. I am on a Mac. This seems to work ok for me on PowerPoint 2016 but does not show up in PowerPoint 2011 which from the screenshot above seems to be what you used on this. Any thoughts?

  2. Thanks again for checking on this for me. Had time to play with it over the weekend and worked as you said across everything but those -- so just will do your suggestion and add those in as a reference page for those using those 2 versions. Thanks for your help -- great series of articles -- has been very useful!!

  3. Thanks very much for the post. I've found this xml hack a while back too and it's proofed very useful. I'm currently exploring ways to write these xml nodes with VBA but so far to no avail. Have you got any hints on how to go about this? Thanks for any pointers you may be able to give me.

    • Unfortunately, there's no way to set a style that automatically removes underlines from hyperlinks in PowerPoint, though the same thing is easy in Word. Instead, you have to work around it with each hyperlink by removing the hyperlink from the text, then adding a transparent shape over top that is hyperlinked. Here's a page from Microsoft with the steps: Remove the underline from hyperlink text This was written for 2007, but applies to all versions of PowerPoint.

  4. Hello All,
    Could one of you steer me in the right direction?

    I have made some custom colours for PowerPoint, and they show up and work well.

    I moved this to other PowerPoint documents by, changing the file name to a .zip, then I copied the '<a:custClrLst...' section into the other PowerPoint documents 'theme1.xml' file. This all worked well.

    So I tried moving the '<a:custClrLst...' section into the 'theme1.xml' for my Word and Excel templates.

    But when i open the Word and Excel templates i cannot see the extra colour menu.

    Any ideas?

    Thanks
    Colin

    • Excel doesn't support custom colors in the theme (why not? good question!). With Word, it may be simpler to save your PowerPoint file as a theme and apply the theme to the Word file using the program interface. That should automatically place the custom colors in the right spot. But I've made a note to write an update about adding custom colors to Word. Thanks!

  5. Thank you for this article John! Just wanted to share how I solved and issue with the custom colors not appearing in Power Point 2016 file.

    I tried to include some custom colors without success and found that after <a / rel="nofollow"> there was an <a> xml seccion that had to be removed for the custom colors to appear in the color picker. Tried inserting the custom color seccions before and after the <a> seccion but the custom colors didn't appear, till I erased all that <a> seccion.

    Thanks for all the great articles.

    Jean Pierre

  6. Thank you SO much for this content! Do you know of a way to override the variants under the accent colors? Those automated values are usually so far off hue or saturation that it's embarrassing!

    • Unfortunately, those colors are created by PowerPoint on the fly. They are not part of the presentation file, so there is no XML to edit. The algorithm is built into the program and is not user-modifiable.

  7. This code worked for me and I've used it in PPT, Excel and Word - though in Word the extended custom colour palette isn't stable (sometimes disappears - I don't understand this)
    I mainly use PPT and Xls however and I love it
    What I'd like to know is... if there is a way to customise the table styles. The design options that come with PPT aren't useful to me. I'd like to be able to put some customed tables in the Table Tools Design Tab. Does anyone know how to do this?

  8. Thanks very much for confirming that the variants - the tints of the accent (theme) colours - were not editable. Thanks also for the xml branching info to add custom colours.

  9. Brilliant - your site is so useful! I have a question about editing XML parts for color and table customisations. I have a lot of documents which were created using a potx template. I then enhanced the template by adding a custom table style, custom colors and a few others things, by unzipping and then editing the xml parts as you explain.

    Now I want to go back to the documents which were created using the original, NON-customised potx, and add the customisations. What is the simplest way of doing this to a whole set of files (apart from manually copying everything into new documents opened from the new template)? Is there a VBA way of doing it? My other thought was a Python script. And one other thing that a quick online search seems to suggest would be something using VSTO, but I don't know anything about Visual Studio and I can't seem to find anything directly applicable to this issue - is there a quick way that is worth the learning curve?

    Any suggestions would be greatly appreciated!

  10. Brilliant site, so useful. Apologies if this is a double-post - I tried earlier and don't see my comment/question.

    I used your explanations to put custom table styles and some custom colors into a potx, which is working great. But I have a bunch of other files that are from the original, non-customised template. Is there a good way of processing all of them so I don't have to manually add/change the XML for each, or manually copy all the presentations to new documents opened from the new template?

    Is there a VBA way to do it? I don't know Visual Studio, and I can't find any obvious way to do this with VSTO via Google. I was also considering writing a Python script. What would be your recommendation for best practice for this?

    Thank you!

    • To get the custom parts in your presentation, you'll have to create a new file from the POTX that has the custom parts, then use Home>NewSlide>Reuse Slides... to import the slides from the presentation that is lacking the custom parts.

      You might think that using the Design tab to apply a custom theme would work, but unfortunately the custom parts do not get copied over this way.

  11. Hi, this is a fantastic post, thank-you very much. I've been successful in applying custom colours into a blank word document, however when I try and adjust the Theme1.xml file in an already mature document the custom colours don't display. In the unzipped folder structure includes a customXml folder.

    Do you know what might be inhibiting the visibility of the custom colours I've added?

    • Hi, after some further testing it seems that the custom colours were applied, however disappear as soon as an object is selected (an object was the first things selected in my template). Do you know how to combat this?

      • When you write "disappear as soon as an object is selected", do you mean the swatches disappear from the color chooser, or that the object color disappears from the object? By object, do you mean an autoshape, or some other object? What version of Word are you using? If you can email the file in question to me at production at brandwares dot com, I'll take a look at it.

  12. Hi John,

    Thank you for your post! One quick question, where can I find recent colors tag? I'm trying to erase all recent colors that I have been using to build the master slide. I found that in Excel is .

    Any help would be appreciated!

    Thanks!

    • As noted above the Comment box, please replace the less than sign "<" with "&lt;" and the greater than sign ">" with "&gt;". Otherwise, WordPress strips out those characters and only a blank space appears on the page.

  13. Just out of curiosity (and my apologies if this has already been addressed), but is it possible to change the text "Custom Colors" to something like "Colors for Charts Only"?

  14. It seems the custom colors are only accessible for fonts, and not backgrounds (Office 2016, Win10). Is that the behavior others see as well?

    • Sorry for the late reply, I had to do some research on this. Custom Colors appear in the Font Fill, Font Outline, Shape Fill, Shape Outline, Table Shading, Table Border Pen Color and Format Background dialogs in PowerPoint. In Word, Custom Colors do not appear in the Table Shading, Table Border Pen Color or Page Color dialogs, but they are available for fonts and shapes. This is true for Office 2007, 2010, 2013 and 2016, plus 2016 for Mac.

  15. Also, a helpful tip for all: If you use 7-zip (free from 7-zip.org), you can (on Windows at least), right click your document and select "Open as Archive". Browse to the file, and select "Edit" from the context menu. Make the desired changes, save, and answer yes to the prompt to change the file in the archive. Fini!

  16. Hi
    I used your example and managed to make it work. I want to ask if there is any way to group my colours, for example to make them appear in multiple lines:
    CL1 CL2 CL3
    CL4 CL5 CL6
    CL7 CL8 CL9
    rather than in one row

  17. Excel question: Is there anyway to automatically apply custom colors to every excel workbook opened (e.g., as part of my personal vba workbook or something)? that way if someone sends me an XLSX it will have my custom colors available?

    • Sorry, as noted in the article, Excel does not recognize custom colors and will not display them in any of the color picker dialogs. This hack only works with Word and PowerPoint.

  18. Hi John,
    Thanks a lot for this tut. Seems easy enough to replicate, however, I feel like I might be a bit late to the "show". I can't seem to make it work. I'm using Powerpoint for Office 365 (2016).
    I made sure that there all ">" and "<" set correctly, and also made sure that there are no soft quotes like "“" and "”".
    After all the modifications, once I doubleclick on the thmx file, the template is opened correctly, all set as intended except for the custom colors.
    Could it be that this is no longer supported? Or do I have to do it differently?

    I have uploaded my theme1.xml file to dropbox, as well as my entire theme file in case this is useful.
    https://qbdclandauer-my.sharepoint.com/:f:/g/personal/daniel_amstutz_qbdclandauer_onmicrosoft_com/EjtURM_xNTRAnd73edBfPwIBOH62ZK_pRSvxWO85GMUbEQ?e=upy9hQ

    Kind regards,

  19. Hi John, is there a way to apply names to "Theme Colors" the same as "Custom Colors"? For example, $lt;a:accent2$gt;$lt;a:srgbClr val="818A37"/$gt; is given the name "Dark Green", and I don't know where that name comes from. Can I name it "Olive" instead? I.e. when resting the mouse in the color picker, I want the name "Olive" to appear instead of "Dark Green". In other words, is there a "name" tag that complements the "val" entry for the theme color? Thanks!

    PS: expecting my comment #23 will be updated with this corrected version using your XML provided instructions (sorry for the confusion).

  20. Hi John,
    Thanks for this! I defined a few custom colors and put them into my Normal.dotm file. These appear fine in a new document. However, they do not show up in a document that has already been created. Any thoughts?

    BTW, they do appear (in the new document) and can be used for table shading, etc. as well as font color.

    • That's normal Word behavior. After a document is spawned from a template, it exists independently unless you actively update it. You can export a theme file, use the same steps to add custom colors to it, then apply it to a Word document and it will update with the custom colors.

      • Thanks. Actually, it was easier than that. I think it is Word Office 365. Under the Design menu, Themes, I simply did Reset to Theme from Template and there they are...
        There are no custom themes, etc. in the document, so no chance of inadvertently screwing anything up. YMMV though.

  21. Hi John. Thank you for this post. Is there a way to hack the colour codes for the tints of each Theme Colour? I often find that I'm not happy with the 5 light and dark tints automatically provided underneath each of the Theme Colours and it would be great if there was a way to change these. Do you have a post on this subject already?

    • Unfortunately, those theme color variants are not stored in the file. Instead Office programs generate them on the fly, so you can't control them or the names they are assigned.

  22. Hi John,

    Thank you for this post! It has been very useful. I have an interesting development: You *can* get custom colors in Excel 2016. Do the following:

    Add custom colors to a theme file and verify that they definitely work via PPT.
    Open up Excel.
    Apply the theme to your spreadsheet.
    Click in a cell and type, then go to the font color menu. No new colors appear!
    Insert a shape into your spreadsheet.
    Select the shape.
    Type in the shape.
    Go to the font color menu. New colors have appeared!

    It seems that Excel does not like to show custom colors in its color menus until the color menu has been "refreshed" with the new colors. I can get the fill, line color, and font color menus to accept the new custom colors this way. I use this for shapes and charts a lot. I haven't succeeded with the border color menus yet. Sometimes Excel forgets this if you close the file so you need to do it again next time you open it.

    This is weird and inconsistent, but you *can* get them in there.

    • Your observations were close enough to get me to take a look at custom colors in Excel more closely. They are never available for Worksheet formatting, like text, or cell fills or borders. Custom Colors do display with most of the items on the Insert menu, like text boxes, shapes, charts, etc. So I've updated the article. Thanks for writing!

      • It seems Kaz is right in saying that in a blank new sheet the custom colors are not immediately available for cell fills etc., but if you insert for example a shape, the custom colors appears. After that, they are also available for cells fills. So it seems one has to "shake them out of bed"...

        It also seems that using only a ThemeColorScheme (xml file) doesn't seem to work for bringing along custom colors. However, applying a whole Theme (thmx file) allows you to bring along the custom colors.

        So another question is: whether it is possible to save the thmx file using VBA? I've searched and searched, but the answer seems to be no?

        Thanks for a great post!

        • In testing Excel 2019, I don't see Custom Colors becoming available for cell fills even after a custom color is applied to a shape. Perhaps you could specify in which version of Excel and operating system you see this happen.

          Here's a line of VBA that will save the active presentation as a full theme file:

          ActivePresentation.SaveCopyAs FileName:="C:\NewTheme.thmx", FileFormat:=ppSaveAsOpenXMLTheme
          • Works on excel 2013. Open xl add text shape, apply custom color to text in text object and custom colors "jump" to the ribbon... Delete shape the colors remain on ribbon until xl is closed.

          • I don't see any colors "jumping" anywhere in any version of Excel. As noted in the article, if a theme containing custom colors is applied to a workbook in Excel, the custom colors can be applied to text boxes, shapes, SmartArt, charts and WordArt. Applying a custom color to a shape is not necessary to make this happen. Custom colors do not remain active in Excel after the workbook with custom colors is closed, they disappear from the interface. Custom colors do not appear when you're formatting worksheet text, cell fills or borders.

    • If you're referring to the tint and tone variants directly below the theme colors, that's not possible. Those are created on the fly by the program.

  23. So when unzipping using terminal I see the files being created but where are these files being saved, there is no new file/folder located in the folder where the original file is located. Can someone hlep me with this?

    • With a standard terminal unzip (unzip path/to/the/zipfile), the unzipped files are normally created in the same folder as the original zip file. To find them, do a Spotlight search for [Content_Types].xml. That file name is only found in OOXML files.

  24. Is it possible to add tiers? For example:
    Custom color tier_1
    50 colors here

    Custom color tier_2
    50 colors here

    Custom color tier_3
    50 colors here

    ...And so on?

    • No, it's not. You get 50 colors maximum. To have more, you would have to use multiple slide masters, but you would then have to switch between color themes to have access to them all.

Leave a Reply

*Required fields. Your email address will not be published.

Posting XML? To enter XML code, please replace all less than signs "<" with "&lt;" and greater than signs ">" with "&gt;". Otherwise, Wordpress will strip them out and you will see only a blank area where your code would have appeared.