|
||
---|---|---|
PowerPoint tips, hints and tutorials that will change your presentations for ever! | ||
Jigsaws |
How to Detect if Dark Mode is Used If you are wrintg code for Office AddIns with custom ribbon images you may want to check if Dark Mode is being used used and specify different ribbon images depending n the mode in use. You can check the Dark Mode type by checking the registry either manually or mor usefully with vba. Registry Key "HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common\UI Theme" How to Check with VBA Sub check_Dark()Dim myRegKey As String Dim myvalue As Long On Error Resume Next myRegKey = "HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common\UI Theme" If myRegKey = "" Then Exit Sub If RegKeyExists(myRegKey) Then myvalue = RegKeyRead(myRegKey) Select Case myvalue Case 3 MsgBox "Dark Gray" Case 4 MsgBox "Black" Case 5 MsgBox "White" Case 6 MsgBox "System" Case 7 MsgBox "Colorful" End Select End If End Sub Function RegKeyRead(s_RegKey As String) As String Dim myWS As Object On Error Resume Next 'access Windows scripting Set myWS = CreateObject("WScript.Shell") 'read key from registry RegKeyRead = myWS.RegRead(s_RegKey) End Function Function RegKeyExists(s_RegKey As String) As Boolean Dim WSO As Object On Error GoTo Err Set WSO = CreateObject("WScript.Shell") WSO.RegRead s_RegKey RegKeyExists = True Exit Function Err: RegKeyExists = False End Function |
|
Articles on your favourite sport Free Microsoft PowerPoint Advice, help and tutorials, Template Links |