I'm trying to find or figure out VBA code for changing the Office 365 themes and colors shown in the attached image. I've found msoThemeColor, and msoThemeColorIndex references on MSDN and sporadically around the net. But nothing at all substantive. I've looked at VBA sites and the MVP sites too, but without success.
My goal is to define my own named theme color set (of some 8 colors and tints and shades), add it to the list somehow, modify it, and delete it from the list later.
Second, once I have it loaded, I want to make my current document use the theme, use the theme tints and shades, and so on.
Does anyone have any pointers or examples that could steer me in the right direction? Thank you
UPDATE: Not wanting to suffer the kiss of death for my question for seeming to be too unfocused, here is some code that I figured out by spending a few hours on the net (almost useless) and in the Word VBA object browser (somewhat useful, I suppose - see the code).
I cannot find the Name field shown in the image below in ANY of the objects that I have inspected, even though the name must be stored somewhere since it is displayed on the screen. I couldn't find even one relevant example on the net in several hours, searching VBA sites, Word sites, MVP sites, or stackexchange.
Dim x As OfficeTheme
Dim mycolor As ThemeColor
Dim mythemecolorscheme As ThemeColorScheme
Dim mycolorindex As MsoThemeColorIndex
Dim mythemecolorschemeindex As MsoThemeColorSchemeIndex
' I have no idea if these statements do anything useful
' And I certainly have not been able to find the Name field in the VBA object browser
' This is all in Word, not Excel
setname = mythemecolorscheme.Colors(msoThemeAccent2)
foobar = mythemecolorscheme.Count
x = OfficeTheme.ThemeColorSchemeIndex(1)
x.ThemeColorScheme.Colors.RGB = RGB(255, 0, 0)
x.ThemeColorScheme.Count
x.ThemeColorScheme.Save (myfilename)
x.ThemeColorScheme.Load (myfilename)
It's like no one has ever tried this before, which is hard to believe.
Thanks, Kevin

Themes are defined in Office Open XML files with a thmx extension. Internally, these "belong" to PowerPoint - if you double-clilck it PowerPoint will open with a new presentation in that theme. But other Office apps use them, as well.
Rename a thmx file with a .zip extension and you can see the XML files that make up a theme. You'll also see the basic PowerPoint presentation defintions.
You can find those Office installs in Program files/Microsoft Office/Document Themes [version number]. Your custom themes reside at C:\Users\[user profile]\AppData\Roaming\Microsoft\Templates\Document Themes.
If you're only interested in the colors, these are straight-forward XML files, as can be found in the Theme Colors folder of either of the paths above. You can define your own color xml file and save it to C:\Users[User profile]\AppData\Roaming\Microsoft\Templates\Document Themes\Theme Colors, where it will be available to all the Office applications. Either open one of these and change it, define your own using the tools available in any Office application, or use (VBA) code to write the file from scratch if you don't want to distribute an XML file with your code.
You load the custom color scheme to Word using
ActiveDocument.Documenttheme.ThemeColorScheme.Load "file path & name*"
For more info, see this useful information as well as the Office Open XML Ecma specifications.
UPDATE: There's a reasonable example in the MSDN documentation here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With