익명 22:48

Registry Editor VBA and native VBA window font height changes will not set font ...

Registry Editor VBA and native VBA window font height changes will not set font to value larger than 10

(This is a follow up to my previous question Excel 365 VBA editor not responding to font size changes)

Basically, my question there was about the fact that, for me on Windows 11/Excel 365/VBA 7.1, the standard way of changing the font size in the Excel VBA editor (Alt+F11->Tools->Options->Editor Format->Size) wasn't working for me. User @Luuk suggested a workaround of changing "Font Height" in the Registry Editor (Win+R->regedit->Computer->HKEY_CURRENT_USER->Software->Microsoft->VBA->7.1->Common->right click Font Height->Modify). They also mentioned that, in older Excel versions, the registry font height was listed as actual_font * 20, but that wasn't the case for me (font height was listed as 9 for an actual font of 9). @Luuk's suggestion worked but only partially. It did change the default font BUT there are a couple of big problems:

  • I can set the font in Registry Editor to whatever I want. However, the font that actually appears in the VBA editor (closing and reopening Excel entirely) keeps being equal to min(10, registry editor font setting). If I set the Registry Editor font to 5, the editor's font becomes 5, but if I set the registry editor font to 12, the VBA editor font becomes 10. (Interestingly, for some absurdly large font height values (such as 500 HEX = 1280 DEC) I was testing the actual editor font became 2.

  • I cannot set the font larger than 10 with the normal VBA Tools->Options->Editor Format->Size method. What I didn't know (or maybe wasn't the case) when I asked the previous question is that I can set it to 8, 9, or 10 (8 being the smallest font size choice in the normal VBA method) but, if I try to set it larger than 10, it reverts to 10.

    Also, changing the VBA editor font using Tools->Options... from the native VBA window changes the registry editor setting. So if I set the registry editor size to 14, the VBA window, as earlier described, is set to 10. If I then try to enlarge the VBA window font size, it reverts to 10, and so does the registry editor entry.

It's as if there's some hard cutoff that says my VBA editor font shall under no circumstances be larger than 10. Is this a known issue? Is there a workaround either with or not involving registry editor?

Again, if possible, I'd like to avoid having to adjust my display size to the recommended value and back over and over.

Also, not sure if it's relevant, but VBA Tools->Options ... WILL let me change the font face, just not the size to the extent desirable.



Top Answer/Comment:

I tested using Excel 2013 (Because that's te version I have installed here).

When changing the value of FontHeight without effect, the probable cause is "windows scaling" (see link at bottom)

A couple of notes:

  1. The possible values for FontSize are: 8,9,10,11,12,14,16,18,24. These can be set under the "Microsoft VisualBasic for Applications"/Tools/Options/"Editor Format"
    • A value of 24, is changed to 23 when using Excel2013
  2. The option to set this via the Registry (HKEY_CURRENT_USER\Software\Microsoft\VBA\7.1\Common\FontHeight) has limitations. Invalid values will be corrected by Excel to some other value. I did not go into details of how/why/results of this.

Some links wit (possible) more info:

P.S. The mention of "older version" in the question:

in older Excel versions, the registry font height was listed as actual_font * 20

Can be ignored. At least since the introduction of 64-bits version of the VBA editor, the config of this was not changed. (see: Compatibility Between the 32-bit and 64-bit Versions of Office 2010), Last updated on 04/27/2015)

상단 광고의 [X] 버튼을 누르면 내용이 보입니다