VBA Editor Themes
By Richard Rost
2 years ago
Customize VBA Editor Themes in MS Access In this Microsoft Access tutorial, I'm going to teach you how to make different themes for your VBA editor so you can switch between a light mode and a dark mode. You can change the font colors, the font size, the font face. We'll learn how to read and write these values to and from the Windows registry. PrerequisitesLinksRecommended CoursesUp Next
Keywords TechHelp Access, VBA Editor Themes, Switch Between Light and Dark Mode, Customizing VBA Editor, Accessing Windows Registry with VBA, Saving VBA Editor Settings, VBA Code for Theme Management, VBA Editor Color Customization, Registry Keys for VBA Editor, Create VBA Editor Profiles
Intro In this video, I will show you how to set up and manage custom VBA editor themes in Microsoft Access, allowing you to save different color schemes and font settings for your VBA editor in a table. We'll create a form to store, organize, and switch between your preferred themes using a little bit of VBA code. You'll see where these settings are stored in the Windows registry, how to safely back up your data before making changes, and how to build the necessary tables and forms to get started. This is part 1.Transcript In today's video, I'm going to show you how to set up VBA editor themes so we can have different color themes in our VBA editor. You can save those themes in a table and use a form with a little bit of VBA to switch between them.
Okay, so last week I released a video called VBA Editor Colors where I show you how to go into the VBA editor and adjust the color settings. Me personally, when I'm working, I like a dark background. I think it's easier to see. I think this guy is a lot easier on the eyes to work with, especially me, I got very poor eyesight. Whereas, the default setting is like this.
Now the comments that I got were everything from, "Oh wow, that's super cool, I'm going to do that," to "Please don't do that, it's very difficult to see in your videos," which after some further thought I kind of agree. This is easier on the eyes as a programmer, but I think it is actually harder to read in my videos. This comes across in the videos a lot easier.
I'm thinking to myself, "Well, self, there's got to be a way to switch between these." Now, there's nothing in the VBA editor itself that allows you to easily and quickly switch between these things. And of course, a few people even mentioned it in comments on my forums and on my YouTube channel, they said, "Well, I think those settings are saved in the registry." Oh yeah, guess what? They are.
With a little bit of VBA code, we can read those settings out of the registry and then write them back, and we can create a table and a little form and save multiple profiles. Make the settings changes in Access, save those to our table, change them again to whatever else you want, save the table again, and now we can flip between them. Okay, basically it's setting up your own theme editor.
So if you haven't watched last week's video on the VBA editor colors, go watch it now. I basically just show you how to set up the different color changes and stuff in the VBA editor itself.
Now before we get started, I'm going to give everybody a warning. Back up your data and make sure you've got a full backup of your PC as well. Windows backup. A good image of your entire drive because, in order to do this, we need to read and write from the registry. If you don't know what the registry is, I'm going to explain it in just a minute, but this is part of Windows and if something goes wrong and you mess up the registry, you could make your system not bootable. I'm just giving everybody the warning before you do this. What I'm showing you should be perfectly safe, but as a disclaimer, you never know. So always make sure you've got a good backup of everything, your databases, all your data, and of course, Windows itself. If you don't have a backup, and if you don't remember when the last time you made a full backup was, now is the time to go do it. Okay? You'll thank me later.
All right, so if you don't know what the registry is, it's basically a database that is stored in Windows, and it keeps settings for Windows itself and most of the other applications that you have on your system. They're all stored in this big database called the registry.
How do you get to the registry? Well, you click on your start button in Windows. You type in regedit, R-E-G-E-D-I-T. That's short for registry editor. You'll get the Windows security pop-up that shows, you know, you're going to have to run this as an administrator. Are you sure? Say yes. I can't show it to you easily on the screen here because it bypasses my video recording software, but then you'll get this thing up. Alright, this is the registry editor, and it might show up like this up top here. Right, there are different groups, there's Classes Root, Current User, Local Machine, there's all kinds of different stuff.
I go over this in a lot more detail in my developer classes, but what you're looking for is under HKEY_CURRENT_USER, right, open them up with these little arrows over here, okay, then SOFTWARE, then MICROSOFT, then come on down to VBA, and then 7.1 or whatever version you have installed on your machine, and then COMMON. This is the registry key we're looking for right here, the folder that the keys are in. And over here are all the keys themselves.
Now I'm just showing this to you for demonstration purposes. We are not going to make the changes directly in the registry editor. This is just to show you where they are, what they look like. There are four that we care about. There's CodeBackColors, CodeForeColors, FontFace, and FontHeight. Those are the only four we're going to mess with. You can play with these other ones if you want to, but do so at your own risk. This is basically a list of the different colors that are specified in the VBA editor itself. When you drop those little color boxes down, all these numbers represent one of those. Same thing with the ForeColors.
We're not going to change them here. We're going to change them in Access and then just save that setting to our database. Same thing with the FontFace, that's pretty straightforward, right, and standard, and then FontHeight, which is a number, we'll get to that in just a few minutes. But again, just showing you where this is, don't mess with it in here, don't touch it inside the registry editor. In fact, you don't even have to open up the registry editor if you don't want to; don't even come in here.
Alright, so let's close that, let's go back to Access. Alright, so here I am in my TechHelp free template. This is a free database you can grab off my website if you want to, but we don't even really need this today. So we're just going to make a table and a form to save our VBA themes in, okay? So let's start with a table create table design. This will be our VBA Theme ID, our autonumber, we'll give it a description. Like light mode, dark mode, teaching mode, whatever you want, whatever mode you want.
Okay, now we need four fields to store the different registry key values. I'm going to use the same names as they are in the registry. So it's CodeBackColors, that's a string, CodeForeColors, we've got FontFace, and then we have FontHeight which is stored as a number, so we'll make that a number here. Okay, save this as my VBA ThemeT table, primary key sure. Okay, close that. Let's make a continuous form out of this. I'm going to take my continuous blank right here, copy, paste, we're going to call this the VBA ThemeF. Let's open her up in design mode, right-click, design mode.
Let's set the record source equal to the VBA ThemeT. Now we can add fields. I'm going to grab all the fields. That's click, shift-click on the last one. Let's drag them all over, just drop them down here in the form footer for now. Okay. Up top, I'm going to put the ID and the description, and then we'll put the values for the keys down in the footer. So we're going to do, I only keep these around here for the format painting. So I'm going to format paint over you, and then these are all fine. So I'm going to grab this and go like this, this, this, this.
Now I'm going to slide the ID over here and get rid of your label. And it doesn't need to be quite that big. And then the same thing with the description. The description there. Change the label up top. And then we've got these guys down underneath. And we'll make these a little bit bigger. Okey dokey. Okey-dokey, all right, so that color, FontSpace, and the FontHeight doesn't need to be that big. Okay, all right.
Alright, so now we're going to save this and let's see what we got real quick. Come back out here, close it, open it, all right, and now we can set up a dark mode and a light mode. What we're going to do is we're going to put two buttons on here: one to get the settings from the registry and save it, and then another one to put the settings that we have in here back to the registry. That's going to involve some VBA code to read and write keys from the registry, and we will talk about that tomorrow in part 2. So tune in tomorrow, same bat time, same bat channel.
Or if you remember, where is it, where's my slide, there it is. If you're a member, you can watch it right now because I'm about to record it in just a few minutes. So that's going to be your TechHelp video for today. I hope you learned something. Live long and prosper, my friends. I'll see you tomorrow in part 2.Quiz Q1. What is the primary purpose of creating a table and a form in Access as discussed in the video? A. To directly edit color themes in the registry editor B. To store and manage multiple VBA editor themes C. To change Access background themes D. To secure registry keys from deletion
Q2. Why should you be careful when working with the Windows registry? A. Because changes may slow down your computer B. Because incorrect changes can make your system unbootable C. Because it may cause your VBA code to not run D. Because it will automatically reset your custom themes
Q3. Which of the following registry fields are used to define a VBA editor theme, according to the video? A. FontColor, FontSize, EditorTheme, EditorView B. BackColor, StyleType, FontName, KeySize C. CodeBackColors, CodeForeColors, FontFace, FontHeight D. ColorMode, Description, AccessMode, UserPrefs
Q4. Where in the Windows registry are the VBA editor color settings located? A. HKEY_LOCAL_MACHINE > SOFTWARE > VBA > 7.1 > COMMON B. HKEY_CLASSES_ROOT > VBA > 7.1 > SETTINGS C. HKEY_CURRENT_USER > SOFTWARE > MICROSOFT > VBA > 7.1 > COMMON D. HKEY_USERS > DEFAULT > VBA > EDITOR
Q5. What did the video specifically warn against when dealing with the registry? A. Creating too many registry backup files B. Editing registry keys by double-clicking them quickly C. Making direct edits in the registry editor unless necessary D. Opening more than one registry editor window
Q6. What data type should be used for the FontHeight field in the Access table, based on the demonstration? A. Text B. Currency C. Number D. Date/Time
Q7. What action did the instructor recommend before changing anything that deals with the registry? A. Clear the Windows cache B. Make a full backup of your data and system C. Log out of all user accounts D. Update all Windows applications
Q8. What will the form eventually include to manage the themes, as indicated in the video? A. A drop-down list for theme selection only B. A single button to delete all themes C. Buttons to read from and write to the registry D. Tabs for each different theme
Q9. The reason for setting up different themes in the VBA editor is mainly to: A. Match the Microsoft Office color schemes B. Make it easier on the eyes and improve readability C. Allow the VBA editor to run faster D. Enable automatic updates from Microsoft
Q10. What is the main function of the CodeBackColors and CodeForeColors fields? A. Store macro security levels for each theme B. Define the background and foreground colors in the VBA editor C. Store font types and sizes only D. Control how registry keys are displayed in Access
Answers: 1-B; 2-B; 3-C; 4-C; 5-C; 6-C; 7-B; 8-C; 9-B; 10-B
DISCLAIMER: Quiz questions are AI generated. If you find any that are wrong, don't make sense, or aren't related to the video topic at hand, then please post a comment and let me know. Thanks.Summary Today's TechHelp tutorial from Access Learning Zone will show you how to organize and manage different color themes for your VBA editor right inside Microsoft Access. I will explain how you can save various themes in a table and use a form, along with some VBA programming, to quickly switch between them.
Last week, I published a video where I demonstrated how to manually adjust the color settings in the VBA editor. Personally, I prefer a dark background while I am working. It is much easier on my eyes, especially since my eyesight is not the best. However, many viewers pointed out that while a dark theme works well for me as a developer, it can be hard to read on videos. After considering their feedback, I agree that lighter backgrounds are clearer for instructional purposes.
This led me to consider ways to switch between different themes quickly and easily. Unfortunately, the VBA editor does not offer any built-in way to change themes with a simple click. Some viewers mentioned in the comments that theme settings are saved in the Windows registry. They are correct. With some VBA code, we can read these settings from the registry, store them in an Access table, and write them back when needed. This allows us to create a set of profiles such as light mode, dark mode, or any other custom configuration.
First, if you have not already watched last week's video about VBA editor colors, I recommend starting there. It walks through how to make these changes manually in the editor.
Before proceeding, I need to give everyone an important warning: always back up your work, and ideally your entire computer, before making any changes related to the registry. The registry is a crucial part of Windows that stores settings for the system and your applications. If the registry gets corrupted, your computer might not start. The process I am going to show you is safe if you follow along carefully, but you never know what can go wrong. Make sure to back up your databases, files, and your system before attempting this. If you cannot remember when you last created a backup, now is a good time to do it. Trust me, it is better to be cautious.
If you are not familiar with the Windows registry, it is essentially a giant database that holds settings for Windows itself and many of your installed applications. To open it, type "regedit" in the Start menu. This launches the Registry Editor (regedit), which you must run as an administrator. Once inside, you will see a list of registry hives like Classes Root, Current User, Local Machine, etc.
For this task, we are interested in the path under HKEY_CURRENT_USER, then SOFTWARE, then MICROSOFT, then VBA, then the version number (like 7.1), and finally COMMON. In this folder, you will find several key settings related to the VBA editor. The relevant keys are CodeBackColors, CodeForeColors, FontFace, and FontHeight. These settings define the colors and fonts the editor uses.
I am only showing you how to find these keys to help you understand where the settings are stored. We are not going to change them directly in the Registry Editor. In fact, you do not even need to open regedit unless you are curious. The changes will be handled from within Access, where we will read and write these settings safely.
Now, let us build the tools in Access. I am using my TechHelp free template, which anyone is welcome to download from my website, but it is not necessary for following along today. We are going to set up a new table and a form to manage our VBA themes.
First, create a table to store your themes. The table needs an ID field (autonumber), a description field (like "light mode", "dark mode", or any other mode you like), and four fields that correspond to the registry settings: CodeBackColors, CodeForeColors, FontFace, and FontHeight. The first three will be text fields and FontHeight will be numeric. Save this table as VBA ThemeT.
Next, build a continuous form based on that table. The form will allow you to create, view, and edit your different themes. Lay out the form so that the ID and description appear at the top, with the registry values underneath. Arrange and size the controls so the form looks clean and is easy to use.
With the table and form set up, you can start populating the table with your favorite themes. You might have a row for dark mode, another for light mode, and perhaps a few others. The last step is to add two buttons to the form: one to pull the current settings from the registry and save them to your table, and another to write a selected theme from the table back to the registry. This part will require some VBA coding to handle reading from and writing to the registry. I will cover that in detail in part 2 of this tutorial.
If you are a member of my site, you can watch the next lesson immediately. For everyone else, be sure to check back tomorrow for part 2, where I will show you the VBA code needed to make this work.
You can find a complete video tutorial with step-by-step instructions covering everything discussed here on my website at the link below.
Live long and prosper, my friends.Topic List Setting up VBA editor color themes Locating relevant VBA registry keys Explaining the Windows registry structure Accessing registry using regedit Identifying CodeBackColors, CodeForeColors, FontFace, FontHeight registry keys Creating a theme table in Access to store theme settings Designing a table for storing VBA editor themes Building a continuous form for managing themes Adding fields and arranging them in the Access form Saving theme data in an Access database
|