PC Review


Reply
Thread Tools Rate Thread

change color scheme in VBA

 
 
Florin
Guest
Posts: n/a
 
      16th Mar 2009
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
 
Reply With Quote
 
 
 
 
Gina Whipp
Guest
Posts: n/a
 
      16th Mar 2009
Florin,

I do not know if there is another way to do but I am curious why you are
changing the color scheme that the User selected as it will change it for
the Office 2007 suite. (Unless there was some update I did not get.) I
would a little annoyed if somone changed my color scheme everytime I opened
a Access database they created. You can make the forms whatever color you
like, so why change the color of the Offices 2007 suite?

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

"Florin" <(E-Mail Removed)> wrote in message
news:11B014CE-FFFD-421F-8D9C-(E-Mail Removed)...
> 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



 
Reply With Quote
 
Florin
Guest
Posts: n/a
 
      16th Mar 2009
Thanks Gina,
My application is a runtime Access front-end. As such, the end user might
have or not Microsoft Office 2007. In case they don't have it they obviously
can't change the color scheme and I don't want them to get stuck with the
default one.

I hope this makes sense.
If you remember the other way to change the scheme please let me know.
Thanks again!
Florin
 
Reply With Quote
 
Gina Whipp
Guest
Posts: n/a
 
      16th Mar 2009
Florin,

I see your point but what if they do?

Also, I did a search and so far I only see that way. It appears like most
programs since the color is set at start up of the application changing it
would require reinitializing. It is the program you are trying to change
the color of not just the forms.

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

"Florin" <(E-Mail Removed)> wrote in message
news:064727AC-1145-41CF-92BE-(E-Mail Removed)...
> Thanks Gina,
> My application is a runtime Access front-end. As such, the end user might
> have or not Microsoft Office 2007. In case they don't have it they
> obviously
> can't change the color scheme and I don't want them to get stuck with the
> default one.
>
> I hope this makes sense.
> If you remember the other way to change the scheme please let me know.
> Thanks again!
> Florin



 
Reply With Quote
 
Florin
Guest
Posts: n/a
 
      16th Mar 2009
My entire application has custom interface options: colors, fonts, backround,
even background images, gradients for header/footer and highlighting for the
buttons on hover. These apply to the forms themselves.
If I can give the option to change the color of the application window as
well, I don't see why I shouldn't.
The more pleasent environment, the better the work.
Thanks again for your help!
F
 
Reply With Quote
 
Gina Whipp
Guest
Posts: n/a
 
      16th Mar 2009
Florina,

Oh, I was not suggesting you shouldn't, just curious as to why.

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

"Florin" <(E-Mail Removed)> wrote in message
news:02E2BC6C-2C46-4825-802B-(E-Mail Removed)...
> My entire application has custom interface options: colors, fonts,
> backround,
> even background images, gradients for header/footer and highlighting for
> the
> buttons on hover. These apply to the forms themselves.
> If I can give the option to change the color of the application window as
> well, I don't see why I shouldn't.
> The more pleasent environment, the better the work.
> Thanks again for your help!
> F



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help With Color Scheme Change Morton Windows Vista General Discussion 3 3rd Aug 2007 12:57 AM
Change the color scheme Prasanna Windows Vista General Discussion 1 11th May 2007 05:09 PM
FSX Color scheme change =?Utf-8?B?TWFzdGVyIENoaWVm?= Windows Vista Games 4 14th Apr 2007 11:13 PM
Change XP Color Scheme? news.microsoft.com Windows XP Customization 3 18th Sep 2004 07:42 PM
Is there anyway to change color scheme of one particular application only ? =?Utf-8?B?ZmFzdGR1bm4=?= Windows XP Customization 0 27th Feb 2004 01:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:41 PM.