How can I use custom colours in the Microsoft VBA editor?

VBA reads the settings for the colors from these registry keys:

HKEY_CURRENT_USER\Software\Microsoft\VBA\6.0\Common\CodeForeColors HKEY_CURRENT_USER\Software\Microsoft\VBA\6.0\Common\CodeBackColors

Each of these keys contains a list of values (separated by space) for each entry inside Tools -> Options -> Editor Format. For example, the first value inside CodeBackColors is the background color and the first value inside CodeForeColors is the foreground color for normal text. The values are the internal id for the color, 0 means AUTO coloring, 11 shows cyan, 5 red etc.

To give it a try: Close Excel, change the first value of CodeBackColors to 5 and restart Excel. The background of the code editor will now be red.

The problem is that the VBA Editor does only support these internal values and the highest number it understands is 16. Any other value will not be accepted and it defaults back to AUTO.

I have tried several options of entering different values (e.g. 128255128, 16777215, #aaffee, 255 or "170,255,238") and none of them worked.

Therefore I think it is technically not possible to assign other colors.


I created an application based on the information found here: https://github.com/dimitropoulos/VBECustomColors

It basically backs up the VBE6/VBE7 .dll file and allows the use of custom colors without having to use an hex editor.

ss

You can download it here: https://github.com/gallaux/VBEThemeColorEditor

Enjoy

Edit: Source code is now available!