OOXML Hacking: Protected Area Exceptions in Word

Microsoft doesn’t have a catchy name for this feature, but I’ll try to describe it. In Word for Windows, you can select document text, then apply Read-only protection, but with Exceptions. By default, the exception is Everyone. If we untangle the word logic, this means that the document becomes read-only except that everyone can edit the selected text. It’s a far better solution than the old protection for forms.

When this type of protection is applied, the selected areas become shaded in light yellow as a visual cue that the highlighted text remains editable. Users of Word 2016 for Mac and 2019 for Mac (including Microsoft 365 subscribers) can use these documents, but can’t produce them. At least, until now.

Light yellow areas indicate editable text
Protected area exceptions in Word

Word pros will look at the square bracket and think it’s a bookmark. It’s not. Microsoft reused the bookmark character to show a Permission Range. To add these editable ranges on a Mac, we’re going to create one manually.

To start, apply Read-only protection to the document. Use Tools>Protect Document, then check Protect document for. Click on Read only, then on OK. Save the file.

Now open the file in your XML editor. OOXML Tools in the Chrome browser is fine for this job. Open document.xml inside the word folder.

Just before the text that you want to be editable, insert a line like this:

<w:permStart w:id="883447734" w:edGrp="everyone"/>

At the end of the editable text, insert this XML:

<w:permEnd w:id="883447734"/>

The beginning and end tag must have the same 9-digit random number. Each pair of tags in a document must have a different random number.

Here is a whole paragraph marked as editable:

<w:permStart w:id="783447734" w:edGrp="everyone"/>
<w:p w14:paraId="5B68C6A9">
  <w:r>
    <w:t>To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other.</w:t>
  </w:r>
</w:p>
<w:permEnd w:id="783447734"/>

Here, just one word is editable:

professionally produced, <w:permStart w:id="983447734" w:edGrp="everyone"/>Word<w:permEnd w:id="983447734"/> provides header,

It’s that simple. Save the file and distribute to users.

For any of our tips that seem too complicated, Brandwares is available to do it for you. We teach the pros!


Fix It with VBA

Instead of hand-editing the XML, then applying Read-only protection, you can use a bit of VBA to solve this problem. Select the text that should remain editable, then run this macro:

Sub CreatePAE()
  Selection.Editors.Add wdEditorEveryone   ActiveDocument.Protect Password:="", NoReset:=False, Type:=wdAllowOnlyReading, UseIRM:=False, EnforceStyleLock:=False End Sub

If you have multiple areas that should remain editable, run the macro, then unprotect the document (Tools>Protect Document>Uncheck Protect document for option), select new text, then re-run the macro. Leave the document protected before distributing it.

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!

OOXML Hacking: Buy the Book

SOLD OUT! The paper copies of the book are all gone, but the ebook version (with an additional 40 pages of new content) is available here.

After years of original research, you can finally buy the book! Filled with unique information not found anywhere else, online or in print, this manual shows you how to build SuperThemes 3 different ways, how to create custom Effects Themes, how to edit the Ribbon in macOS, and much more!

OOXML Hacking: buy the book

The book expands on many of the brief articles on this site, putting them in logical order and expanding the number of examples. Author John Korchok explains how Office Open XML files work, shows you where to find each XML part and how each part can be modified. With these tools, you can provide unique services to your clients or users that you can’t find at the average Office template service bureau. To give you a better idea of what it covers, here is the Table of Contents:

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

All techniques are covered in both Windows and macOS. The book includes a link to a downloadable text file with all the hyperlinks, XML and VBA listings, so you don’t have to retype anything from the printed page. At this time, only print copies are available, ebook versions will be here in several months. To buy the book, click here.

Presentation Summit 2019

This October 6 – 9 in San Antonio, the world’s top presentation experts will be meeting at the Presentation Summit 2019. This is the place to learn how to make amazing presentations that sparkle, or network with pros who can make you shine.

For the first time, Brandwares will be a sponsor. I’ll be attending with my new book OOXML Hacking. In addition to expanded versions of my online articles, put in a logical sequence, there are new chapters from our original research. I show you three ways to build SuperThemes, how Effects Themes work and how to create them, plus much more information that can’t be found anywhere else, in print or online.

Indezine.com, the media sponsor for the Presentation summit was kind enough to interview to find out more. Here’s is the result:

Uniform Rounded Corners – Cool Code

A client sent a design for a Word template that had lots of boxes and photos with uniform rounded corners. Not an unreasonable request, but Office doesn’t do that well. In PowerPoint, Word and Excel, rounded corners are proportional to the size of the shape. Making them uniform manually is picky and time-consuming. But with a dash of VBA, we can make the job easy.


The Math

As a round-cornered shape gets larger, the corner radius increases as well, in proportion to the length of the shortest side of the shape. Since we want to keep the radius the same size, we need to create a formula that makes a smaller number as the shorter side increases. We need an inverse number! We can create this by dividing the preferred corner radius by the short side size. And you thought you’d never need that high school math!

Here’s VBA code that will work in Excel, Word and PowerPoint on selected round-cornered boxes. Thanks to the Rembrandt Kuipers and Ernst Mathys who have commented below, this macro has been improved since it was originally published. Replace the number after sngRadius with your desired radius size in points.

Sub RoundedCornersFixedRadius()
    Dim oShape As Shape
    Dim sngRadius As Single
    sngRadius = 8.50394 'Radius size in points. 8.50394pt is equal to 3mm.

    For Each oShape In ActiveWindow.Selection.ShapeRange
        With oShape
            If .AutoShapeType = msoShapeRoundedRectangle Then
                LengthOfShortSide = IIf(.Width > .Height, .Height, .Width)
                .Adjustments(1) = sngRadius / LengthOfShortSide
            End If
        End With
    Next oShape
End Sub

To set rounded corners on a PowerPoint placeholder, open Slide Master view, select the placeholder and run the above macro.


Uniform Rounded Corners for the Whole Document

To run this on a whole presentation, document or workbook, we need to customize the routine for each Office program. Here’s the Excel version:

Sub RoundAllXLCorners()
    Dim oWorksheet As Worksheet, oShape As Shape, sngRadius As Single
    sngRadius = 8.50394 'Radius size in points.

    For Each oWorksheet In ActiveWorkbook.Worksheets
        For Each oShape In oWorksheet.Shapes
            With oShape
                If .AutoShapeType = msoShapeRoundedRectangle Then
                    LengthOfShortSide = IIf(.Width > .Height, .Height, .Width)
                    .Adjustments(1) = sngRadius / LengthOfShortSide
                End If
            End With
        Next oShape
    Next oWorksheet
End Sub

To do the same in PowerPoint

Sub RoundAllPPCorners()
    Dim oSlide As Slide, oShape As Shape, sngRadius As Single
    sngRadius = 8.50394 'Radius size in points.

    For Each oSlide In ActivePresentation.Slides
        For Each oShape In oSlide.Shapes
            With oShape
                If .AutoShapeType = msoShapeRoundedRectangle Then
                    LengthOfShortSide = IIf(.Width > .Height, .Height, .Width)
                    .Adjustments(1) = sngRadius / LengthOfShortSide
                End If
            End With
        Next oShape
    Next oSlide
End Sub

And finally, for Word

Sub RoundAllWDCorners()
    Dim oShape As Shape, sngRadius As Single
    sngRadius = 8.50394 'Radius size in points.

    For Each oShape In ActiveDocument.Shapes
        With oShape
            If .AutoShapeType = msoShapeRoundedRectangle Then
                LengthOfShortSide = IIf(.Width > .Height, .Height, .Width)
                .Adjustments(1) = sngRadius / LengthOfShortSide
            End If
        End With
    Next oShape
End Sub
Before: Rounded Corners, but not Uniform
Rounded Corners, but not Uniform

The Word version is a little simpler because a Word document is one big object, while Excel and PowerPoint both have multiple objects for each worksheet and slide, respectively. But the similarites point out that when you’re searching online for VBA code, finding something for a different program and modifying it can be a huge time-saver. By far, Excel has way more code written for it, so Excel VBA sites can be a fruitful source for Word and PowerPoint code ideas.

After: Uniform Rounded Corners
Uniform Rounded Corners

These macros have been tested under both Windows and macOS and work well under both.

To use these macros with other shapes, please see my article Every AutoShape – Cool Code for a downloadable reference file showing all AutoShapes along with their XML and VBA names. Then replace msoShapeRoundedRectangle with the mso shape name you need.

Content Controls for macOS – Cool Code

June 2023 Update: I’ve created a VBA add-in for Word for Mac that allows you to more easily add Content Controls in Word documents, with an interface similar to the Windows version. I’m looking for beta testers for this add-in. If you have time to test, please email me (my address is in the Meet the Author sidebar).

Content Controls are an improved form of fillable form field, but the Word for Mac user interface doesn’t include Content Controls for macOS. I show you how to sidestep this limitation to be able to create superior fillable forms.

Microsoft Word for Windows has three different types of fields to use for fillable forms. The oldest of these are Legacy Form Fields, which exist in every version of Word, Windows and Mac, but not DOS, back to the dawn of time. Legacy form fields require the document to be protected for forms, which closes down many formatting options even on unprotected sections. These are the only form fields available in the Mac program interface. Windows version also have ActiveX controls. These generally have a crude appearance. They don’t work at all on Mac versions of Word.

Finally, we have the newest type of form fields, Content Controls. These were introduced on Windows in Word 2007. The collection of controls was expanded a little in 2010 and a little more in 2013. Word 2008 and 2011 can’t use or create them, but in Word 2016 for Mac, the program started honoring Content Controls created in Windows, so they work as expected on both platforms. Unfortunately, the tools to add and modify them are still not in the program.


Content Controls for macOS: What Are They?

While Legacy Form Fields have only 3 types (Text field, Checkbox and Dropdown), there are 9 (or 10, depending on how you count) types of Content Controls. Here’s a look at each type:

Plain Text and Rich Text
Plain Text and Rich Text Appearance

These look identical on the screen. The screen shot shows what they look like unselected (top) and selected (bottom). The Plain Text control is most similar to the Legacy Text form field. All the text has the same formatting and you can’t include other types of content other than text. By comparision, the Rich Text control allows selected text to be bold or italic or a different font. You can insert tables and pictures and even other Content Controls into Rich Text controls.

Picture
Picture Control Appearance

Finally! A true picture placeholder for Word! The picture can be set when the control is created. There are options to allow the user to replace it or not. Or it can be left blank (as shown) for the user to add a picture later. You can change the shape from a square using Picture Format>Picture Styles. This choice can also add a soft edge or other visual effects to a photo that the user inserts later.

It’s worth noting that Picture Content Controls only work as inline pictures. To float them and wrap text around them, you need to place the CC in a table cell or frame or some other object that allows text wrapping. These controls come in at 2″ square, but you can set numeric dimensions on the Picture Format tab. (Thanks to Timothy Rylatt for the tips!)

Building Block
Building Block Control Appearance

This is the only Content Control that doesn’t work yet on a Mac. While Building Blocks in the Windows version of Word is the same technology as AutoText on the Mac, Microsoft hasn’t gone the extra mile to make it work on a Mac. The macro further down the page sets the control to work with AutoText (as you almost always should if your template is being distributed to others). But when you click on the control’s AutoText tab, a dropdown list of AutoText entries doesn’t appear like it does in the Windows version.

At least if your Windows client needs it in their template, you can create it on a Mac. AutoText works by grabbing content from the active document’s attached template. If you’re sending a template with AutoText content, the Content Control will find that. If you’re sending a document instead of a template, the Content Control will grab AutoText from the user’s Normal.dotm file.

Check Box
Checkbox Appearance

Similar to the Legacy Check Box form field, but with the added advantage that the filled symbol can be set to other symbols than an X. This control was added in Word 2010, so don’t include one for a client using 2007.

But still no radio buttons? Give me a break, Microsoft! Using elaborate VBA kludges, it’s possible to make a set of checkboxes operate like radio buttons with both Legacy and Content Control versions. But it shouldn’t be so hard!

Combo Box and Drop-Down
ComboBox and Dropdown Appearance

Another similar pair of controls. The Drop-Down is most similar to the Legacy Drop-Down (which MS often refers to as a Combo Box, just to confuse everyone). The Drop-Down restricts users to choosing an item on the list, while a Combo Box allows a user to enter a value that is not on the list.

Date Picker
Date Picker Appearance

While Legacy Text fields have a date option, it’s only to enforce date formatting after a user tries to enter a date. The Date Picker Content Control is way cooler, it’s pops a little calendar for the user to choose a date visually. Handy!

Repeating Section
Repeating Section Appearance

…And the prize for longest prompt text goes to this control. Added to Word 2013, so it won’t work for 2007 and 2010 clients. Clicking on the plus sign in the bottom right corner duplicates the content. There are already a couple of ways to do this, so I think this is strictly for user convenience. Unlike the others, this control spans the page by default, probably because of the long prompt.

Group

No screen capture for this one, because it’s more of an operation than a control. Applying this to a selected set of Content Controls will group them together, so they can be copied as a unit. You can’t include a Rich Text control, which can also be used as a group. If you select controls, then get an error when grouping that a control is “partially covered”, it will usually be about the topmost control. Add a carriage return before, include it when you select, then run the Group macro.


Simple Controls from Keyboard shortcuts

Fortunately, the VBA object model for Word 2016 and 2019 for Mac includes Content Controls. If you’re creating forms for your own use, there is a simple way to create basic Content Controls on your Mac:

  1. In Word, choose Tools>Customize Keyboard
  2. Scroll Categories and pick All Commands
  3. Scroll Commands and pick ContentControlCheckBox
  4. Click inside the Press new keyboard shortcut field and type a key combination. Word will inform you if that combination is already in use. If there is no conflict, or an insignificant conflict, click on the Assign button. Finally, click on OK. The Control key is a good modifier, because all existing keyboard shortcuts with Control are duplicates of ones that also use the Command key.
  5. Click on your document where you would like to see a checkbox, then use the keyboard shortcut. Viola! Instant checkbox!

Repeat the steps for the other Content Control commands. It’s not a bad idea to make a sample document with Content Controls and their shortcuts, for later reference. BTW, keyboard shortcuts are the only customization that can access Content Controls. Equivalent commands for the QAT and Ribbon haven’t been added as of this writing.


Content Controls for macOS: Complex Controls for Clients

The keyboard shortcuts are fine for plain vanilla controls. But they’re so basic, some are useless. Sure you can insert a Drop-Down or Combo Box, but they don’t have any items in the list and there’s no easy way to add them. What we need is more fine-grained control so we can set all the same options that a Windows user can. This is possible by inserting them using VBA.

If you never used macros in Word, start by making the Developer tab visible on the Ribbon. Choose Word>Preferences>View and check Show developer tab. The tab becomes visible when you close the Prefs panel.

On the Developer tab, click on the Visual Basic button (Word doesn’t run Visual Basic, but a very similar language called Visual Basic for Applications. This is VBA, not VB, but why would MS care about an accurate button title?). The VBA Editor opens. In the top left corner is a windows called Projects. If you have a fresh installation, you’ll only see Normal here. If you have Add-ins installed, there will be other project names. Select Normal.

From the macOS menu, choose Insert>Module. Call it ContentControls. A new module page is opened where you can insert macro code. Copy and paste the following code onto that page:

Sub AddRichTextCC()
  Dim oCC As ContentControl
  Set oCC = ActiveDocument.ContentControls.Add(wdContentControlRichText, Selection.Range)
  Set oCC = Nothing
End Sub
Sub AddPlainTextCC() Dim oCC As ContentControl Set oCC = ActiveDocument.ContentControls.Add(wdContentControlText, Selection.Range) With oCC .MultiLine = True End With Set oCC = Nothing End Sub
Sub AddPictureCC() Dim oCC As ContentControl Set oCC = ActiveDocument.ContentControls.Add(wdContentControlPicture, Selection.Range) Set oCC = Nothing End Sub
Sub AddBuildingBlockCC() Dim oCC As ContentControl Set oCC = ActiveDocument.ContentControls.Add(wdContentControlBuildingBlockGallery, Selection.Range) With oCC .BuildingBlockType = wdTypeAutoText .BuildingBlockCategory = "General" End With Set oCC = Nothing End Sub
Sub AddCheckBoxCC()
  Dim oCC As ContentControl
  Set oCC = ActiveDocument.ContentControls.Add(wdContentControlCheckBox, Selection.Range)
  With oCC
    .Checked = False
    .SetCheckedSymbol CharacterNumber:=&HFE, Font:="Wingdings"
    .SetUncheckedSymbol CharacterNumber:=&HA8, Font:="Wingdings"
  End With
  Set oCC = Nothing
End Sub
Sub AddComboBoxCC() Dim oCC As ContentControl Set oCC = ActiveDocument.ContentControls.Add(wdContentControlComboBox, Selection.Range) With oCC .DropdownListEntries.Add "Choose an item.", value:="" .DropdownListEntries.Add "Item 1" .DropdownListEntries.Add "Item 2" End With Set oCC = Nothing End Sub
Sub AddDropDownCC() Dim oCC As ContentControl Set oCC = ActiveDocument.ContentControls.Add(wdContentControlDropdownList, Selection.Range) With oCC .DropdownListEntries.Add "Choose an item.", value:="" .DropdownListEntries.Add "Item 1" .DropdownListEntries.Add "Item 2" End With Set oCC = Nothing End Sub
Sub AddDatePickerCC()
  Dim oCC As ContentControl
  Set oCC = ActiveDocument.ContentControls.Add(wdContentControlDate, Selection.Range)
  With oCC
    .DateDisplayFormat = "MMMM d, yyyy"
    .DateDisplayLocale = wdEnglishUS
    .DateCalendarType = wdCalendarWestern
  End With
  Set oCC = Nothing
End Sub
Sub AddRepeatingSectionCC() Dim oCC As ContentControl Set oCC = ActiveDocument.ContentControls.Add(wdContentControlRepeatingSection, Selection.Range) With oCC .AllowInsertDeleteSection = True .RepeatingSectionItemTitle = "Repeating Section Item" End With Set oCC = Nothing End Sub
Sub AddGroupCC() Dim oCC As ContentControl Set oCC = ActiveDocument.ContentControls.Add(wdContentControlGroup, Selection.Range) Set oCC = Nothing End Sub

Use the Tools>Customize Keyboard command to assign these macros keyboard shortcuts. You can also add them to the Quick Access Toolbar. If you subscribe to Office 365 or have Office 2019, you can also add them to the Ribbon.

If you take a close look at the code, you’ll see there are additional lines on some that allow you to set options for that type of control. As one example, the Date Picker includes options for the calendar type, date format and date language. In use, you would alter these options to suit the client, then run the macro to add a control with those options set.


Content Controls for macOS: Setting the Options

Here’s where you can really customize the Content Controls. These are generic options that can be set for all Content Controls. Rather than bulk up each individual macro, here’s one macro to set the extra options. Set the options in code, select a Content Control that you’ve already inserted, then run the macro. If you’re inserting many controls that have a common setting, like .LockControl = True, add that line to the code for inserting the control to avoid extra steps.

Sub SetOptions()
  If Selection.Information(wdInContentControl) Then
    With Selection.ParentContentControl
      'Sets the appearance to the original bounding box look. For the newer tags look, use wdContentControlTags
      'If you don't need to change a setting, comment it out before running the macro
      .Appearance = wdContentControlBoundingBox
'Sets the color of the control to a preset color .Color = wdColorWhite
'Sets the Word Character style to use for the text formatting. This will fail if you use a Paragraph style or forget to create the style before running this. This does _not_ change the placeholder text appearance, just the entered text that replaces it. .DefaultTextStyle = "Big"
'Sets whether the Content Control can be deleted or not. If the control has had .Temporary = True applied, you must reverse that property to True before applying this. .LockContentControl = True
'Sets whether the contents of the Content Control can be deleted or not. .LockContents = False
'Sets the placeholder text or prompt for the control .SetPlaceholderText , , "Default Text"
'Sets the Content Control tag property .Tag = "Tag"
'If this is set to true, the Content Control will be removed when the contents are edited. .Temporary = False
'Sets the title of the Content Control. This appears on a tab above the control when it is activated. .Title = "Title" End With Else MsgBox "Please select a Content Control to change its options." End If End Sub

Perhaps you need to create a date picker in a different language. Starting with the macro above for U.S. English dates, you can modify it to create a French date picker:

Sub AddFrenchDatePickerCC()
  Dim oCC As ContentControl
  Set oCC = ActiveDocument.ContentControls.Add(wdContentControlDate, Selection.Range)
  With oCC
    .DateCalendarType = wdCalendarWestern
    .DateDisplayFormat = "d MMMM yyyy"
    .DateDisplayLocale = wdFrench
  End With
  Set oCC = Nothing
End Sub

Utility Macros

The following macros perform essential functions that may only be occasionally required. First, a pair to toggle all Content Controls between the older Bounding Box appearance and the newer Tags look. The only control that currently displays as a tag in macOS is the Group Content Control. All others appear as plain text in a mysterious field. As a consequence, don’t use this setting for forms to be used on a Mac. Save it for Windows clients:

Sub BoundingBoxAppearance() 'Sets all Content Controls in the document to a bounding box appearance
  Dim oCC As ContentControl
  For Each oCC In ActiveDocument.ContentControls
    oCC.Appearance = wdContentControlBoundingBox
  Next oCC
  Set oCC = Nothing
End Sub
Sub TagAppearance() 'Sets all Content Controls in the document to the tag appearance. Dim oCC As ContentControl For Each oCC In ActiveDocument.ContentControls oCC.Appearance = wdContentControlTags Next oCC Set oCC = Nothing End Sub

This macro deletes the existing list of a Combo Box or Drop-Down and replaces it with a new list.

Sub ReviseComboBoxOrDropDownList()
  If Selection.Information(wdInContentControl) Then
    If Selection.ParentContentControl.Type = wdContentControlComboBox Or Selection.ParentContentControl.Type = wdContentControlDropdownList Then
      With Selection.ParentContentControl
        .DropdownListEntries.Clear
        .DropdownListEntries.Add "Choose an item.", value:=""
        .DropdownListEntries.Add Text:="List Item 1", value:="1"
        .DropdownListEntries.Add Text:="List Item 2", value:="2"
      End With
    End If
  Else
    MsgBox "Please select a Combo Box or Drop-Down Content Control to change its list."
  End If
End Sub

Finally, one to ungroup a Group Content Control. Switch to Tag view to see Groups, they’re invisble in Bounding Box view. Don’t try to select all group items before ungrouping, it will generate an error. Instead, single-click anywhere inside the group:

Sub UnGroupCC() 'Ungroups a group control
  If Selection.Information(wdInContentControl) Then
    Selection.ParentContentControl.Ungroup
  End If
End Sub

For more in-depth reference on these macros, please see Microsoft’s documentation.

Now you’re equipped to send your client top-quality fillable forms with the latest technology. So when your client asks if you can create Content Controls, instead of saying “Huh?”, you can reply confidently “No problem!”

Logos Over Photos – Best Practices

Back at the dawn of time, when PowerPoint was first being programmed, a fateful and incorrect decision was made. Placeholder content would always appear in front of static content, regardless of how placeholders and other content were stacked on the layout. This has led to countless bald designers, from them tearing out their hair because there’s no way to place logos over photos.


The Locked Graphics Workaround

One way to circumvent this design flaw is to place a picture placeholder on the layout as usual. Then create a sample slide from it. Place the logo over the photo and lock its position in the XML. Here’s my article on how to do that: OOXML Hacking: Locking Graphics. This allows the user to replace the photo while keeping the logo in front.

The disadvantage is that you can’t create a new slide from the layout. Instead, the user must copy and paste the sample slide to create another one.


The Background Picture Fill Workaround

If the photo is a full-screen photo, there’s another method. This time, don’t place a picture placeholder on the layout. Instead, just place the logo there. In use, the user right-clicks on the background and chooses Format Background. On the Format Background task pane, choose Picture or texture fill, then click on the File button and choose the background photo. The logo will stay on top.

The disadvantage to this technique is you have to include instructions to the end user, who may never have used a picture fill previously. My thanks to Jaakko Tuomivaara of Supergroup Studios in the UK for this tip.


The Holey Placeholder Workaround

For simple logos, or logos contained in a simple shape like a circle or square, create a logo-shaped hole in the placeholder. Here’s a Windows-only version.

  1. On the layout, create the picture placeholder.
  2. Insert the logo as an EMF vector file, then ungroup it twice, confirming with PowerPoint that you want to do this. This changes it from a placed picture to a set of vectors embedded on the layout.
  3. With the logo parts selected, hold the Shift key and click on the placeholder.
  4. Choose Drawing Tools Format>Merge Shapes>Subtract.
  5. Fill the background, or a shape placed behind the logo hole, with the logo color.

If the logo is in a shape, you can use similar steps on both Windows and macOS computers. Using Mac command names: Place the logo over the placeholder, then draw a Shape exactly the same size as the logo, placed over the logo precisely. Select the shape and the placeholder, then use Shape Format>Merge Shapes>Fragment, then delete the shape to reveal the logo-sized hole in the placeholder. For some reason, Merge Shapes>Subtract works differently on a Mac, deleting both the shape and the placeholder, but Fragment still get the job done. Thanks to Ute Simon for suggesting this method in the comments.

A variation on this that can be more detailed is to place a copy of the logo above the placeholder. Then, shape-by-shape, use the logo over the placeholder with the Combine variant of Merge Shapes to knock holes in the placeholder. Then add colored shapes below the placeholder to “fill” the holes. If you have compound shapes (like the letter O or A), you’ll have to release the compound shapes, then connect the inner shape with the outer one. Here’s what the end result looks like in Illustrator.

Outside line connected to inside to simulate a compound shape
De-compounded letter shapes

Logos Over Photos: The Placeholder Picture Fill Workaround

This works with any size photo, it doesn’t have to be full-frame like the previous hack. No copy and paste, no instructions required. I heard about this one from Joshua Finto (Make It So Studio in Austin, TX).

On the layout, insert a picture placeholder to hold the photo. Then add another placeholder on top, sized to exactly the same size as the logo. I use Online Image placeholders because they are rarely used, using a common placeholder type risks content being placed in it if you change layout types. Remove bullets, if there are any, and type a space character so no placeholder text appears.

In the Format Picture task pane, click on Picture or texture fill, then on the File button and fill the placeholder with the logo. Create a slide, place a photo and voila! The logo appears over top of the photo! After creating this, it’s wise to lock the placeholder in XML on that layout, to prevent distortion by the user playing with it. OOXML Hacking: Locking Graphics. EMF, SVG and transparent PNGs are all good logo formats for this application.

Microsoft maintains Feedback forums to collect feedback from users. I’ve created a suggestion there that the placeholder/shape stacking order on the layout should be respected on slides. Please add your vote here: Placeholders Should Not Pop to the Front. Perhaps we can persuade Microsoft to fix the mistake so we don’t need these time-wasting workarounds.

Thanks to my readers who have added some useful suggestions! Please read the comments for additional ideas and tips.

OOXML Hacking: Notes Page Repair

A bug in PowerPoint Online can wreck presentations edited there. This article describes the symptoms and how to do a notes page repair – if you use Windows. Mac users cannot fix this issue because of sloppy Microsoft programming in the macOS version.

PowerPoint Online can resize the Notes Master page of a presentation. It can also resize elements on the Notes Master, leading to a really wacky combination of large and small placeholders. Almost always, the page size is made much smaller, often into a thin but tall rectangle. The exact cause hasn’t been determined yet, but it may be caused by editing Notes. PowerPoint Online can’t display either the Notes Page or the Notes Master for a presentation, so this problem goes undetected until the presentation is downloaded and viewed in the desktop version. Do a quick Google search on notes page wrong size site:microsoft.com to see lots of examples.

There are three steps to a notes page repair, and it starts with an XML hack. Open up the presentation in BBEdit or OOXML Tools (macOS) or unzip it (Windows). Find the presentation.xml part. In human-readable form, the 13th line will be the Notes Master page size. This example shows the normal values:

<p:notesSz cx="6858000" cy="9144000"/>

The hack involves resetting these values to normal, then saving and closing, or rezipping the files. But that’s just 1 of 3 steps. The next 2 steps can be done in the program.

Open the presentation in PowerPoint, then choose View>Notes Master. Very likely there will be wrong-size shapes or missing elements. To fix this, uncheck, then recheck each of the 6 elements (Header, Slide image, Footer, Date and Time, Body and Slide Number). This restores them to the designed co-ordinates.

Uncheck and Recheck

The third step notes page repair is to reset each Notes Page to follow the Notes Master. This is where the Mac version runs into trouble. In the Windows version of PowerPoint, open the Notes Page for each slide and right-click on the background. This is the context-aware menu you’ll see:

Notes Page Context Menu in Windows

Click on Notes Layout, then on Reapply master. The Notes Page reverts to correct formatting.

Now let’s look at the same operation on a Mac. Right-click on the Notes Page and what do we see?

Notes Page Context Menu in MacOS

This is not a “context-aware” menu. This is exactly the same menu that you get if you right-click on a slide. The available commands make sense for a slide, not for a notes page. There is no option to reset the page to the Notes master. The Mac programming team got lazy and just reused the same menu.

As a result, Mac users can’t complete a notes page repair. They can’t reset the page back to the original format.

But wait! What’s that? I hear you say, you read about a macro that can reapply the Notes master. Yup, it’s here on Steve Rindsberg’s awesome PPTFAQ site: Reapply the Notes Master to each Notes Page in a presentation. Except that macro raises an error on Mac version of PowerPoint, because the control ID can’t be found.

Microsoft has f***ed this one badly. First, through the PowerPoint Online bug that creates this, and remains unfixed until the date of this post. Second, because of the sloppy “context-aware” menu programming. And third because they can’t provide PowerPoint for Mac with a complete list of controls in the VBA object model.

As a last resort, create a new blank presentation from the same template as was used for the original file. Then copy and paste the slides from the damaged deck into it. Thanks to Christa Barnes for this suggestion in the comments.

Since I first wrote this article, John Wilson in the UK has written a pair of Windows-only repair utilities to fix this problem. Here’s the page where you can download both, one to fix the Notes Master and another to reapply the master to the Notes Pages. Give them a try, it’s a little easier than revising the XML.

As always, if you’re new to this topic, please review the page about editing OOXML files. Mac users should also read XML Hacking: Editing in macOS. I value your feedback, please leave a comment about any concerns or questions.