PDA

View Full Version : [SOLVED] etting VBE Options Programatically



Cyberdude
09-14-2005, 10:21 AM
Is there a way to change the VBE options like color programatically?

Bob Phillips
09-14-2005, 10:53 AM
I think not, I don't believe the properties are exposed.

Cyberdude
09-14-2005, 10:56 AM
I was afraid you'd say that. I looked and looked but couldn't find anything. Oh, well ...
Thanks for the reply, xld.

Marcster
09-14-2005, 11:13 AM
A couple of things I've found out about the VBE:

Some of the VBE settings are held in the registry:
HKEY_CURRENT_USER\Software\Microsoft\VBA

If you set a reference to the file VBE6EXT.OLB in the object browser. You can
view the objects and properties which you can change via VBA.

Although this doesn't answer your question, I thought it might help in pointing you in the direction to what is possible to code via VBA in regards to programming the VBE.

But I reckon you knew this anyway.

Cyberdude
09-14-2005, 04:25 PM
Yes, that's interesting stuff. I'll follow up on it. Thanx, Marcster :friends:

gibbo1715
09-15-2005, 12:54 AM
Some of the VBE settings are held in the registry:
HKEY_CURRENT_USER\Software\Microsoft\VBA

If you set a reference to the file VBE6EXT.OLB in the object browser. You can
view the objects and properties which you can change via VBA.

Looks very interesting, does it put the objects into my object browser once i create a reference then and is there a way to just look at the objects from that location?

Cancel that, clearly it does now i ve found my way around the object browser a bit better, very useful

thanks

Gibbo

Marcster
09-15-2005, 01:59 AM
Hi people :hi:,

I know this thread is closed but have been looking abit more into this (you need some knowledge of the Registry) and found:

Using Excel 2000 the VBE editor colours seem to be held in the registry is this location:

BE VERY CAREFUL WHEN BROWSING/CHANGING VALUES IN YOUR REGISTRY AS ONE FALSE MOVE CAN MAKE YOUR PC UN-BOOTABLE !!!

HKCU\Software\Microsoft\VBA\6.0\Common\CodeForeColors

If you don't find the registry key, go into the VBE options and change the Syntax Error Text in Code Colors on the Editor Format tab of the VBE options dialog.

The registry location should display a row of numbers like "0 0 7 0 1 10 14 0 0 0 0 0 0 0 0 0 ", don't know what they mean but they change value when you change the colors in the Code Colors section in the Editor Format tab in the VBE options dialog.

If you can work out what the numbers mean, then you could write a procedure using WScript.Shell. You need a reference to "Microsoft Scripting Runtime" though, file name: scrrun.dll

But why would you want to be able to change the VBE colours via VBA? :dunno

Marcster

Cyberdude
09-15-2005, 09:03 AM
Yes, why would I want to do such a thing? Well, I recently sent a copy of a workbook to a gent who had difficulty reading the Excel sheet because he is color blind and he couldn't adjust to the colors I use for myself. I added a button to the sheet so that he or anyone else can quickly change the sheet colors to white background and black text. That helped him a lot. Then it occurred to me that I hadn't done anything to change the colors on the VBE. So I decided to look into it to see if I can change those color programatically. You never know how someone else will react to your own beautiful color scheme. They may very well be unable to read it!

TonyJollans
09-15-2005, 09:41 AM
Well, yes, it is true that the VBE colours are held in the registry and you can change them that way, but

The settings in the registry are loaded when VBA is initialised within an application and not released until the parent application is closed. When you make a change via the GUI, the VBE changes its settings and updates the registry. If all you do is change the registry, your change will not take effect until the next time the VBE is initialised.

So if you've already been into the VBE (and found out the colors aren't what you want) and then you run code to change the registry setting, you will then have to quit the parent application and restart it for the change to take effect.

Cyberdude
09-15-2005, 11:02 AM
Hmmm, that doesn't sound like a slick technique then.