F
Florin
Hi,
I'm using Access 2007.
I'm trying to change the Office color scheme from VBA. I'm completely hiding
the ribbon so I can only do that from code.
I'm using right now a code that is changing a registry entry.
Unfortunately I need to restart Access for this option to take effect.
Any idea how to do this better?
This is the code right now:
'-----------------------------------------------------------------------------
' Utilities from http://blog.nkadesign.com/microsoft-access/
' (c) Renaud Bompuis, 2008
' Licensed under the Creative Commons Attribution License
' http://creativecommons.org/licenses/by/3.0/
' http://creativecommons.org/licenses/by/3.0/legalcode
'
' Free for re-use in any application or tutorial providing clear credit
' is made about the origin of the code and a link to the site above
' is prominently displayed where end-user can access it.
'-----------------------------------------------------------------------------
Option Compare Database
Option Explicit
'-----------------------------------------------------------------------------
' Enums to easily refer to the correct color scheme.
'-----------------------------------------------------------------------------
Public Enum OfficeColorSchemes
InvalidScheme = -1
BlueScheme = 1
SilverScheme = 2
BlackScheme = 3
End Enum
'-----------------------------------------------------------------------------
' Set MS Office to the given Color Scheme.
' Use WarnUser:=false to disable the notification
' The change is not immediate and will only be effective after the
application restarts
'-----------------------------------------------------------------------------
Public Sub SetOfficeColorScheme(scheme As OfficeColorSchemes, Optional
WarnUser As Boolean = True)
On Error GoTo ErrLbl
If scheme = OfficeColorSchemes.InvalidScheme Then Exit Sub
API_Registry.RegSetValueNum API_Registry.HKEY_CURRENT_USER,
"Software\Microsoft\Office\12.0\Common\", "Theme", scheme
If WarnUser Then
Dialog.Box "The change will take effect the next time" & vbCrLf &
"the application is launched.", vbOKOnly + vbInformation, "Changing Theme"
End If
Exit Sub
ErrLbl:
If err <> 0 Then MsgBox err.Description & " - " & Erl() & ": " & "
(SetOfficeColorScheme)", vbCritical, "Error"
End Sub
Thanks!
Florin
I'm using Access 2007.
I'm trying to change the Office color scheme from VBA. I'm completely hiding
the ribbon so I can only do that from code.
I'm using right now a code that is changing a registry entry.
Unfortunately I need to restart Access for this option to take effect.
Any idea how to do this better?
This is the code right now:
'-----------------------------------------------------------------------------
' Utilities from http://blog.nkadesign.com/microsoft-access/
' (c) Renaud Bompuis, 2008
' Licensed under the Creative Commons Attribution License
' http://creativecommons.org/licenses/by/3.0/
' http://creativecommons.org/licenses/by/3.0/legalcode
'
' Free for re-use in any application or tutorial providing clear credit
' is made about the origin of the code and a link to the site above
' is prominently displayed where end-user can access it.
'-----------------------------------------------------------------------------
Option Compare Database
Option Explicit
'-----------------------------------------------------------------------------
' Enums to easily refer to the correct color scheme.
'-----------------------------------------------------------------------------
Public Enum OfficeColorSchemes
InvalidScheme = -1
BlueScheme = 1
SilverScheme = 2
BlackScheme = 3
End Enum
'-----------------------------------------------------------------------------
' Set MS Office to the given Color Scheme.
' Use WarnUser:=false to disable the notification
' The change is not immediate and will only be effective after the
application restarts
'-----------------------------------------------------------------------------
Public Sub SetOfficeColorScheme(scheme As OfficeColorSchemes, Optional
WarnUser As Boolean = True)
On Error GoTo ErrLbl
If scheme = OfficeColorSchemes.InvalidScheme Then Exit Sub
API_Registry.RegSetValueNum API_Registry.HKEY_CURRENT_USER,
"Software\Microsoft\Office\12.0\Common\", "Theme", scheme
If WarnUser Then
Dialog.Box "The change will take effect the next time" & vbCrLf &
"the application is launched.", vbOKOnly + vbInformation, "Changing Theme"
End If
Exit Sub
ErrLbl:
If err <> 0 Then MsgBox err.Description & " - " & Erl() & ": " & "
(SetOfficeColorScheme)", vbCritical, "Error"
End Sub
Thanks!
Florin