OOXML Hacking – Lighting Controls for 3D

Office has the abilty to insert 3D models and to create 3D shapes. Both of these using lighting, but the Office interface does not include any lighting controls. To change 3D lighting, you have to hack the XML.

There is very little documentation online for 3D lighting in OOXML aside from the Microsoft pages at 2.31 http://schemas.microsoft.com/office/drawing/2017/model3d. The am3d element that represents 3D models does not appear in the older ECMA-376 reference that defines the Office file formats. ECMA 376 has been superceded by ISO/IEC 29500-1:2016.

When a 3D model is inserted in an Office document, the model file is storeed in the media subfolder, along with a PNG rendering of the view of the model when the document was saved. The PNG is displayed when the document is re-opened and serves as a fallback image when the file is viewed in an earlier version of Office that doesn’t support 3D models.

The rendering information for the model is stored in the document, not in the embedded model file. In Word, the rendering information is stored in word/document.xml. In PowerPoint, it is kept in ppt/slides/slideX.xml, where X is the slide index number. In Excel, look xl/drawings/drawingX.xml.

3D models use scrgbClr parameters for lighting color with numbers expressed in a percentage. But unlike scrgbClr elsewhere in Office, the syntax is not r=”50%” g=”50%” b=”50%”. Instead, use whole numbers with three zeros added, so 50% becomes 50000: <a:scrgbClr r=”50000″ g=”50000″ b=”50000″/>

Here is a typical lighting section for a 3D model or shape:

<am3d:ambientLight>
    <am3d:clr>
        <a:scrgbClr r="50000" g="50000" b="50000"/>
    </am3d:clr>
    <am3d:illuminance n="500000" d="1000000"/>
</am3d:ambientLight>
<am3d:ptLight rad="0">
    <am3d:clr>
        <a:scrgbClr r="100000" g="75000" b="50000"/>
    </am3d:clr>
    <am3d:intensity n="9765625" d="1000000"/>
    <am3d:pos x="21959998" y="70920001" z="16344003"/>
</am3d:ptLight>
<am3d:ptLight rad="0">
    <am3d:clr>
        <a:scrgbClr r="40000" g="60000" b="95000"/>
    </am3d:clr>
    <am3d:intensity n="12250000" d="1000000"/>
    <am3d:pos x="-37964106" y="51130435" z="57631972"/>
</am3d:ptLight>
<am3d:ptLight rad="0">
    <am3d:clr>
        <a:scrgbClr r="86837" g="72700" b="100000"/>
    </am3d:clr>
    <am3d:intensity n="3125000" d="1000000"/>
    <am3d:pos x="-37739122" y="58056624" z="-34769649"/>
</am3d:ptLight>

The first section is am3d:ambientLight that controls the ambient (background directionless) light. Set the color with am3d:clr and the intensity with am3d:illuminance. The illuminance n and d parameters represent the numerator and denominator of a ratio. So the default values of n=”500000″ d=”1000000″ are equivalent to 1/2 or 50% brightness.

After that, the are three point lights (am3d:ptLight). You don’t have to use all three. You can delete them from the XML, comment them out or use the enabled parameter to turn them off:

<am3d:ptLight rad="0" enabled="false">

The rad parameter sets the radius of the light. The units are EMUs (English Metric Units), where 1 inch has 914,400 EMUs and 1 centimeter equals 360,000 EMUs. Set this number in the millions to have a noticeable effect.

You can also add more point lights, but usually three is enough. The color and intensity parameters work the same way as the ambient light.

The other major parameters are for the position of the lights. The left-right position is set by the x number. 0 is dead center, positive numbers move the light to the right and negative numbers to the left. The y number controls the position up and down, while z controls the in-out third dimension. This line would place the light inside the model:

<am3d:pos x="0" y="0" z="0"/>

The pos units are also EMUs. Use tens of millions to notice the effect.

After making changes to the XML and re-opening the presentation with the model, the appearance will be the same as before you edited it. This is because PowerPoint displays a PNG of the model, created when you save. To display the revised lighting, you must make a small change to the model so PowerPoint updates the appearance.

Most Recent Office You Can Run – Best Practices

As Apple and Microsoft release new operating systems, it’s no longer possible to install the latest version of Office on your old computer. Here’s is a list of the most recent Office you can run for the operating system you have, plus where to find it.


Most Recent Office You Can Run on macOS (Updated for 2024)

Rant alert! Microsoft supports the last three operating systems in both Windows and Mac. Unfortunately, Apple has a policy of releasing a new operating system every year, whether we need it or not. The result of these two business decisions is that there are rafts of perfectly serviceable Macs out there that can no longer install the current version of Office. It looks like Apple intends us to toss them and buy new ones. Another case of lip service to environmental sustainability. Rant over

If you buy or subscribe to Office for Mac today, you’ll only find the current versions of Microsoft 365 (the subscription version) and Office 2021 (the retail edition) to be easily available. But Microsoft maintains a page of older installers at Update history for Office for Mac. All of them can be activated under a current Microsoft 365 subscription or Office 2021 license.

Please note that all of these are final releases: there will be no security updates to follow. Be careful when downloading Office files from the interweb.

At the time of writing, the current crop of obsolete Macs are those that can only run Big Sur (macOS 11). These are machines that are around 10 years old, but are completely useable for applications like Office. The last Office version that Big Sur can run is 16.77. At the History page, look for the Office Suite Installer, with or without Teams, dated September 12, 2023. Do not download the updaters for individual programs! Download the Office Suite installer!

Then run the downloaded installer. After installing, normally Microsoft AutoUpdate fires up and installs the final 16.77 version. Wait until it finishes, then open Applications and run one of the Office apps.

Prompt to sign in.

You’ll see a dialog prompting you to sign into your account. Enter your name and password.

Enter your Microsoft Account email and password.

If you’re a Microsoft 365 subscriber, that should be the end of the process. Your software will be activated and you’re good to go.

If you have purchased multiple permanent license editions, you’ll see a dialog asking to to choose which license to apply. Office 2019 and 2021 no longer have separate licenses for Mac and Windows, so at this point it possible to switch Office 2019 (for example) from Windows to macOS or vice versa.

Choose an Office license to use with your installation.


Older Editions of macOS

Catalina (macOS 10.15) can run Office 16.66. At the History page, look for the Office Suite Installer, with or without Teams, dated October 11, 2022. Reminder: Do not download the updaters for individual programs! Download the Office Suite installer!

Office for Mac Update History

Catalina was the first OS to require 64-bit software. This requirement made Office 2011 obsolete, since it’s 32-bit. But Office 2011 is still a useful edition in macOS. It can still do things that were permanently removed from later versions of Office. So you might want to stick with Mojave and install the newer Office that goes with it. (There’s no problem in having Office 2011 and a later version installed on the same computer.) In this scenario, download and install the 16.54 version dated October 12, 2021.

One of my favorite Macs is my 17″ MacBook Pro. It’s the machine that travels with me, but it’s 12 years old and can run only High Sierra. The most recent Office you can run on this computer is 16.43, dated November 10, 2020.

There’s a pattern here: Apple releases new operating systems in the fall, usually in September or October. The Office version that Microsoft releases the same month is the last one for the fourth-oldest macOS. I don’t have any machines running Sierra, but if I did, I would try the October 15, 2019 edition of Office 16.30.

As I mentioned earlier, you can run an older version of Office on an older computer. Since Office 2008, the file format has remained pretty constant, so the software can still be useful. You can install Office 2011 under Mojave or earlier, while Office 2008 can be installed under El Capitan and earlier. These versions can co-exist on a Mac with a newer version (or with each other), though Microsoft’s History page only goes back to 16.27 from July, 2019.


Most Recent Office You Can Run on Windows

Under Windows, the situation is easier, as Microsoft waits about 3 years between operating systems. Plus Windows isn’t as finicky about the hardware it runs on. I have an old Mac Pro from 2006 that can only run OS X Lion and Office 2011, but under Boot Camp it does either Windows Vista and Office 2010, or Windows 7 and Office 2016. Windows 8 is likewise limited to Office 2016, while Windows 10 (now 9 years old!) can run the current version of Office 2021 and Microsoft 365. You have to have a really old Windows computer to be unable to run a useable copy of Office.

PowerPoint Icon Gallery – Cool Code

Years ago, Ken Puls of the excellent Excelguru site published an Excel add-in that displays the icons built into Excel. This reference is useful for any programmer wanting to repurpose built-in icons to use with their own code. Here’s where you can download the original: Office 2007 Icon Gallery. His version has gradually become outdated as Microsoft has added more icons to the software, and there was no version for PowerPoint. The latter isn’t such a big deal, because Excel, Word and PowerPoint share a common library of icons.

With Ken’s gracious permission, I’ve created an updated PowerPoint version of this add-in. This displays all the icons in current versions of Office, and it runs under PowerPoint for Windows and for Mac.

This is version 2. If you downloaded this prior to January 24, 2023, please download and install this improved version. I haven’t created an installer for this, but here are the instructions for manual installation:


PowerPoint Icon Gallery Installation

Download Link

Icon Gallery Add-in Download

Windows Installation

The download is a zip file that holds a single Icon Gallery.ppam file. Expand the zip and copy the .ppam file to your desktop or other easy-to-find location. Here’s how to make it appear in PowerPoint for Windows:

  1. In PowerPoint, choose File>Options>Add-ins.
  2. Change the Manage dropdown to PowerPoint Add-ins, then click on the Go button. The Add-ins dialog opens.
  3. Click on the Add New button. Navigate to the location where you saved the .ppam file, select it and click on OK. The Add-ins dialog should look like this, displaying the add-in name with a check mark beside it:
    Windows Add-in Dialog
  4. Click on the Close button.
  5. In PowerPoint, select the View tab. At the right end, you should see a new group called Office Icons:
    Office Icon group

macOS Installation

  1. In PowerPoint, choose Tools>PowerPoint Add-ins from the macOS menu bar. The Add-ins dialog opens.
  2. Click on the Plus (+) sign. Navigate to the location where you saved the .ppam file, select it and click on OK.
  3. PowerPoint will pop up a macro warning. Click on the Enable Macros button.
  4. Then PowerPoint will pop up this dialog, astoundingly badly worded, even for Microsoft:
    Turn Off Macro Virus Protection
    It sounds like you’re turning off macro protection completely, right? Well you’re not. This just turns it off for this file, and it has no effect on the macro virus protection settings, so there’s nothing to even turn on again! Click on Turn Off.
  5. The Add-ins dialog should look like this, displaying the add-in name with a check mark beside it:
    Icon Gallery Add-in
  6. Click on the OK button.
  7. In PowerPoint, select the View tab. At the right end, you should see a new group called Office Icons:
    Icon Gallery on View tab

Using the PowerPoint Icon Gallery

Windows Useage

Click on one of the galleries to see a group of icons. Here are the first 256:
Gallery 1 Icons

Hover over an icon to see its idMso command name.

Click on an icon to open a dialog that shows the command name for use with idMso or imageMso commands. Click on the Copy to Clipboard button to copy the command name. Then paste the name into your XML or other code. Due to a bug in File Explorer, all Explorer windows must be closed for this to work as expected.

macOS Useage

Click on one of the galleries to see a group of icons:
Icon Gallery - Mac
Note the grey spinning icons: Those are objects that exist in the Windows version, but not in macOS. One of the drawbacks of trying to develop for both platforms is that Microsoft has only done half the job in Office for Mac. Avoid these icons for cross-platform macros.

Hover over an icon to see its idMso command name.

Click on an icon to open a dialog that shows the command name for use with idMso or imageMso commands. Click on the Copy to Clipboard button to copy the command name. Then paste the name into your XML or other code.


Uninstalling the PowerPoint Icon Gallery

Windows Uninstall

  1. In PowerPoint, choose File>Options>Add-ins.
  2. Change the Manage dropdown to PowerPoint Add-ins, then click on Go.
  3. Select the add-in, then click on the Remove button. Close the dialog. The icon gallery disappears from the View tab.

macOS Uninstall

  1. In PowerPoint, choose Tools>PowerPoint Add-ins (on the macOS menu bar).
  2. Select the add-in, then click on the Minus sign (-). Close the dialog. The icon gallery disappears from the View tab.

Notes

Wouldn’t it make more sense to have this on the Developer tab? Well, yes, it would, that’s where the Icon Gallery appears in Ken Puls’ original add-in. But I made one file to work on both Windows and macOS. PowerPoint for macOS is missing the Developer tab. So I put this on the View tab as a second-best location.

Why no icon preview, as in Ken’s original add-in? Previewing icons in VBA relies on the CommandBars.GetImageMso command. This has been deprecated and in recent versions of Office, does not deliver an accurate icon preview. The command is not available at all on Macs, so I removed the preview. But you can see the 32 x 32 version of the icon in the gallery dropdown, not much has been lost.

Chart Templates – Best Practices

Chart Templates allow you to capture and reproduce the appearance of sample charts. This avoids having to include sample charts for users to copy and paste. Here’s how to use them:


Installing

Chart templates must installed to a particular folder so Office can find them.

Windows Installation

  1. Open a File Explorer window.
  2. In the address field, paste in: %appdata%\Microsoft\Templates.
  3. If there isn’t a Charts folder there, create one.
  4. Copy the chart template(s) into it.

macOS Installation

  1. While holding down the Option key, click on the macOS menu bar. Choose Go, then Library. The hidden user Library folder opens.
  2. Open ~/Library/Group Containers/UBF8T346G9.Office/User Content/Chart Templates.
  3. Copy the chart template(s) into it.

Using Chart Templates

Chart templates can be used in Word, Excel and PowerPoint. Here’s how to access them:

Windows Usage

  1. In the Office program, choose Insert>Chart.
  2. In the Insert Chart dialog, click on the Templates icon.
  3. Select the chart template in the right-hand pane, then click on OK. A chart is inserted in your document.

macOS Usage

  1. On the Insert tab, choose Charts>Templates and select the template from the pop-up list. A chart is inserted in your document.

For more information about creating chart templates that work better then the Microsoft default, please see OOXML Hacking – Chart Template Colors

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.

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.

Text Effects? Don’t! – Best Practices

The Best Practice is to NOT use Text Effects in Office. Ever.

That could have been my shortest article ever, but I guess I should explain the reasons. I’m referring to the graduated fills and lines, the glows, reflections, shadows and 3-D effects you can add to text. In the past these effects have caused some problems with ordinary shapes, but with text, they’re a disaster.

Text Effects: Bad in PDFS

Clearly, it’s not enough for most users that these effects are visually hideous. That just a natural result of the low value we assign to arts education. In many years of working with competent graphic artists, I’ve never been asked to create any template that uses these effects. Designers understand the need for restraint, users don’t. And so we get the appalling appearance of most Word and PowerPoint documents.

But the functional problem with these effects is how they affect PDFs created from Word, PowerPoint and Excel. Microsoft has no clue how to export true PostScript of the fancy effects. So they adopt a simplistic approach: flatten them to graphics. Unfortunately, this means the text vanishes, leaving behind only a pretty picture. Well, not even that. All kinds of PDF functions are impaired: Text to speech is impossible, accessibility goes right out the window, reimporting the PDF to Office is brain-dead.

I tested PDFs created in 3 ways: saving to PDF in Office, printing to Acrobat and printing to the Microsoft Print to PDF print driver that comes with Windows 10. When saving to PDF, all text with applied effects was flattened. When printing to either Acrobat or Microsoft Print to PDF, Gradient Fills, Gradient Lines and 3D Effects were flattened, while Shadows, Reflections and Glows remained as live text.

The moral is clear: when the client asks for Text Effects, just say NO!

Every AutoShape – Cool Code

There are more AutoShapes in Office than appear in the user interface. Over time, Microsoft has quietly added to the collection stored in Office. Many of the more recent shapes are used in SmartArt files, while others have no current use that I can detect. But for anyone who hacks XML or codes VBA will find this week’s download or every autoshape a useful reference.

These are all the shapes that can be used in a piece of SmartArt. This is a deep topic: SmartArt XML is a programming language with a Frankenstein syntax. But the starting point for any language is to get the names right. SmartArt and VBA both reference the AutoShapes collection in Office, but they use different names for the same objects. Many of the same shapes are seen in the Shapes dropdown of Office programs, but those names are also different. The main source of the VBA names are from this page: MsoAutoShapeType enumeration (Office), while the XML names come from this out-of-date listing: SmartArt AutoShapes.

So, for my own sanity, I created a Word document showing an example of each shape, along with it’s name in XML, in VBA and in the user interface. This has smoothed out my workflow, and it may help you as well.

Listing of every AutoShape

For any non-interface shapes, you can insert them into a document with code analogous to this. For PowerPoint:

Sub MakeShape()
  ActivePresentation.Slides(1).Shapes.AddShape msoShapeTrapezoid, 24, 24, 144, 144
End Sub

Change the bolded word to the shape name in the VBA MsoShapeType Name column.

Some shapes have specialized VBA commands, like callouts:

Sub MakeShape()
  ActivePresentation.Slides(1).Shapes.AddCallout msoCalloutTwo, 24, 24, 144, 144
End Sub

Callouts led me to a discovery about legacy versions. msoCalloutOne gives exactly the same result as msoCalloutTwo in current versions of Office.That seemed odd, so I ran the same macro in PowerPoint 2003 (I still have it installed for its macro recorder). In that version, msoCalloutOne creates a callout with a vertical leading line that can be moved up and down, but not at an angle. Presumably, MS found that useless and deprecated it.

Download the Word document showing every autoshape here.

OOXML Hacking: Open XML Explained

We’re proud to be hosting a free e-book Open XML Explained. Finding readable explanations of how Office Open XML works isn’t easy. Outside of the very dense published ECMA standards, most of the information exists only on the web in help pages and blog posts. Back in 2007, a developer in the Netherlands, Wouter van Vugt, published a well written PDF that goes into details about the XML formats used in Word, Excel and PowerPoint. This was originally posted on the openxmldeveloper.org website run by OOXML genius Eric White.

Eric’s site closed down some years ago and much of the content disappeared. But I’ve been able to track down a copy of Wouter’s book and have his permission to give it a new home here at Brandwares. Download Open XML Explained.

The e-book covers Excel, Word and PowerPoint in depth, covering otherwise obscure topics like table formatting, bullets and charts. It’s an excellent companion to my book, covering the theory behind my practical techniques. OOXML hackers will appreciate the explanations of all the major XML parts in an Office file, while coders will find this a useful resource in learning how to programmatically create and modify documents, workbooks and presentations.

Open XML Explained

I should note that Open XML Explained was written in 2007, so while it covers all the OOXML basics, it doesn’t have any information about newer features like the Backstage or SuperThemes. Reader David Wiggins was kind enough to find the sample files that accomapied the book. The download page has a link to them as well. Enjoy!