VBE custom code colors (syntax highlighting) (1 Viewer)

AHeyne

Registered User.
Local time
Today, 04:25
Joined
Jan 27, 2006
Messages
91
I'm just wondering that here in the forum the topic of custom code colors in the VBE is not so widespread.

I can't imagine for the life of me to code with the default colors of the VBE anymore.


First a small digression to the topic "VBEThemeColorEditor":​


In the past years, I still consciously developed with Microsoft Access 2013 (MSI setup).

There I used the VBEThemeColorEditor (https://github.com/gallaux/VBEThemeColorEditor) to patch my desired colors into the "Vbe7.dll" to be able to create a Monokai-like scheme.

However, this procedure also had disadvantages:
- After patching the DLL, Microsoft Access always crashed when I activated the "Editor Format" tab in the VBE under "Tools / Options".
But I was able to fix that, as discussed here: https://github.com/gallaux/VBEThemeColorEditor/issues/11.
- If Microsoft made changes to the DLL by an update, I had to patch the new version again accordingly. But even that worked.
- However, since I switched to Microsoft Access 2016 (C2R setup) due to Microsoft's lack of further support for Microsoft Access 2013, Microsoft quite often replaces my patched DLL with the original version. And I have to copy my patched version back into the appropriate folder. This is annoying.


Now to the actual topic:​


So I looked to see if I couldn't get something reasonably maybe Monokai-like with the original colors, where I don't have to patch the DLL at all, but use the original version.

The result is this color and font configuration:

Code.png


I'm more than happy with this.

Who wants to try it can import this registry file:

```
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\VBA\7.1\Common]
"FontHeight"=dword:0000000c
"FontCharSet"=dword:00000000
"FontFace"="Consolas"
"CodeBackColors"="4 3 4 7 6 4 4 4 0 0 0 0 0 0 0 0 "
"CodeForeColors"="8 1 5 4 1 3 2 12 0 0 0 0 0 0 0 0 "
"CodeBackColorsOriginal"="0 0 0 7 6 0 0 0 0 0 0 0 0 0 0 0 "
"CodeForeColorsOriginal"="0 0 5 0 1 10 14 0 0 0 0 0 0 0 0 0 "
```

The registry file only changes settings that can be set in the VBE under "Tools / Options" on the "Editor Format" tab, so no 'tricks' are used.

Font name, size, foreground and background colors are set.
The original Microsoft colors are stored in the additional "*Original" values.

If you have already configured your own colors there, you should save them beforehand, e.g. using the registry editor under "HKEY_CURRENT_USER\Software\Microsoft\VBA\7.1\Common".
It is sufficient if you rename the values "CodeForeColors" and "CodeBackColors" to "MyCodeForeColors" and "MyCodeBackColors", then they cannot be overwritten and you can restore them in the registry editor later on if you want.

And of course I'm also very curious to see which colors you have configured in your VBE.
 

AHeyne

Registered User.
Local time
Today, 04:25
Joined
Jan 27, 2006
Messages
91
Another addendum to the topic Indicator Colors.

Unfortunately, the VBE (at least for me) does not save the configured values.

But I found out by trial and error that you can configure them in the registry in the same place.

You have to create a 'REG_SZ' value called "IndicatorColors" with corresponding values (the structure is the same as e.g. "CodeForeColors").

These values will then be read correctly at least when loading the VBE.

I was also able to find out the following information myself:

The default value for the registry value "IndicatorColors" is therefore (with the space at the end)

Code:
0 0 0 7 6 0 0 0 11 9 0 0 0 0 0 0

The digits 1-10 of the respective values (11-16 are unused)

Code:
| Position | Name                 | Default Color | Default Color Value |
| -------: | :------------------- | :------------ | ------------------: |
|        1 | Normal Text          | Auto          |                   0 |
|        2 | Selection Text       | Auto          |                   0 |
|        3 | Syntax Error Text    | Auto          |                   0 |
|        4 | Execution Point Text | Yellow        |                   7 |
|        5 | Breakpoint Text      | Maroon        |                   6 |
|        6 | Comment Text         | Auto          |                   0 |
|        7 | Keyword Text         | Auto          |                   0 |
|        8 | Identifier Text      | Auto          |                   0 |
|        9 | Bookmark Text        | Aqua          |                  11 |
|       10 | Call Return Text     | BrightGreen   |                   9 |

Color values

Code:
| Color value | Name        |
| ----------: | :---------- |
|           0 | Auto        |
|           1 | White       |
|           2 | Silver      |
|           3 | Gray        |
|           4 | Black       |
|           5 | Red         |
|           6 | Maroon      |
|           7 | Yellow      |
|           8 | Olive       |
|           9 | BrightGreen |
|          10 | Green       |
|          11 | Aqua        |
|          12 | Teal        |
|          13 | Blue        |
|          14 | DarkBlue    |
|          15 | Fuchsia     |
|          16 | Violet      |
 

MsAccessNL

Member
Local time
Today, 04:25
Joined
Aug 27, 2022
Messages
184
Thx for the infoI have been experimenting with the gallaux code to. I am currently using a QHD screen and i want to make the font size in the nav pane and in the vbe explorer pane bigger, do you know a hack to do this?
 

AHeyne

Registered User.
Local time
Today, 04:25
Joined
Jan 27, 2006
Messages
91
No, unfortunately not, since I have not had the requirement so far I have never looked for it. I am on 23" with 1920*1200.
 

Mike Krailo

Well-known member
Local time
Yesterday, 22:25
Joined
Mar 28, 2020
Messages
1,036
Here's the one I use. The font here is Source Code Pro.
1690722951347.png

1690722558775.png
 

sonic8

AWF VIP
Local time
Today, 04:25
Joined
Oct 27, 2015
Messages
998
- However, since I switched to Microsoft Access 2016 (C2R setup) due to Microsoft's lack of further support for Microsoft Access 2013, Microsoft quite often replaces my patched DLL with the original version. And I have to copy my patched version back into the appropriate folder. This is annoying.
Microsoft does not necessarily redistribute the "original version" of the DLL. It it is probably a new version that includes relevant changes.
So, if you then replace a new version delivered with an Microsoft update with and old, already color-patched version, you combine an old version of the VBE with a new version of Office that was never meant to be run in this combination.

Instead: Apply the color-patch to the new version of VBE that was installed with the update.
 

AHeyne

Registered User.
Local time
Today, 04:25
Joined
Jan 27, 2006
Messages
91
Hi Philipp,
I'm aware of this, that was how I did long time with Access 2013.
But since I switched to Access 2016 the patched DLL will be replaced by the same unpatched binary file which I patched before.
I made backups of the patched DLL and its original and when Microsoft replaced it I compared them binary.
This never happened when I used Access 2013. There it only has been replaced when Microsoft made changes to the dll, so when they released a new version.
I expect that behaviour comes from the C2R environment.
 
Last edited:

MsAccessNL

Member
Local time
Today, 04:25
Joined
Aug 27, 2022
Messages
184
My attention is drawn by the SaveBeforRun setting. Sometimes when I edit my code (without saving) and i run it with an error, the changes are gone, could this be an option that the code is automatically saved before running the code?
 

Attachments

  • SaveBeforRun.PNG
    SaveBeforRun.PNG
    128.9 KB · Views: 60

Users who are viewing this thread

Top Bottom