none
Determining the Office-Theme via VBA RRS feed

  • Question

  • Hello everybody,

    is there a way to determine which office-theme is currently set using VBA? I'd like to adjust the icons in my custom ribbon according to the the theme in use (white, dark grey or colorful).

    Kind regards
    Michael

    PS: I've searched both the net and this forum quite some time, so forgive me if I've overlooked an existing post.

    Friday, August 11, 2017 4:00 PM

Answers

  • The Office Theme is not exposed in the VBA object model.

    You can retrieve it from the registry. The DWORD value

    HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common\UI Theme

    stores the theme value (note: 16.0 is for Office 2016; for Office 2013 it is 15.0).

    In Office 2016, the values are:

    0 = Colorful
    3 = Dark Gray
    4 = Black
    5 = White

    In Office 2013, the values are:

    0 = White
    1 = Light Grey
    2 = Dark Grey

    (Don't you love the consistency?)

    Example for Office 2016:

    Dim strValue As String
    Dim lngTheme As Long
    strValue = "HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common\UI Theme"
    lngTheme = CreateObject("WScript.Shell").RegRead(strValue)


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by MicTh Sunday, August 13, 2017 9:21 AM
    Saturday, August 12, 2017 6:05 PM