Can't change vba project font size

Jeff H
4StarLounger
Posts: 415
Joined: 31 Oct 2017, 20:07

Can't change vba project font size

Post by Jeff H »

I posted this question on the Microsoft Forum some time ago and HansV kindly replied, but didn't have an answer, so I thought I'd try here.

I'm running Excel 2016 on Windows 10. In the VB Editor I go to Tools > Options > Editor Format and change the font size from the default 9 to 12 (because my eyes are too old for 9!). The change appears in the Sample box, but when I exit the dialog there's no change. When I open the Options box again it's back to 9. I can change the font style (although I don't want to) but not the size.

Anybody here have a fix for that?

Thanks,
- Jeff

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Can't change vba project font size

Post by HansV »

Welcome to Eileen's Lounge!

You could try setting the font size in the registry. Do this while Excel is not running.

- Click the Start button or press the Windows key.
- Type regedit and then press Enter.
- If Windows ask for permission, click Yes.
- Navigate to HKEY_CURRENT_USER\Software\Microsoft\VBA\7.1\Common
- Double-click the FontHeight property in the right-hand pane.
- Set the value to C (hex) or 12 (decimal).
- Click OK.
S1910.png
- Start Excel and activate the Visual Basic Editor.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

Jeff H
4StarLounger
Posts: 415
Joined: 31 Oct 2017, 20:07

Re: Can't change vba project font size

Post by Jeff H »

HansV wrote:Welcome to Eileen's Lounge!

You could try setting the font size in the registry. Do this while Excel is not running.

- Click the Start button or press the Windows key.
- Type regedit and then press Enter.
- If Windows ask for permission, click Yes.
- Navigate to HKEY_CURRENT_USER\Software\Microsoft\VBA\7.1\Common
- Double-click the FontHeight property in the right-hand pane.
- Set the value to C (hex) or 12 (decimal).
- Click OK.
S1910.png
- Start Excel and activate the Visual Basic Editor.
Very clear instructions and easy to follow ... unfortunately it didn't work. I tried a few times, including with reboots. The registry takes the change and retains it even when I close and reopen Regedit or reboot the computer. But when I open VBE the font (Courier New (Western)) is still 9, and when I close Excel, the registry reverts to 9 as well. I also tried manually changing it in the Project Options box, but got the same results as always. It appears to be something within Excel or the VBE.

It couldn't be just my instance of Excel, right??

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Can't change vba project font size

Post by HansV »

The problem is mentioned in other forums, for example in Can't change font size in VBA Code Editor in MS Access 2016. It appears to be related to the text scaling setting in Windows, in Start > Settings > System:
S1911.png
Some people report that the font size in the Visual Basic Editor cannot be increased if text scaling is set to for example 200%, but it is possible if text scaling is set to 100%.
In the thread I mentioned above, the original posted wrote that the problem was solved in an update to Office 2016 earlier this year. Is your Office fully updated?
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

Jeff H
4StarLounger
Posts: 415
Joined: 31 Oct 2017, 20:07

Re: Can't change vba project font size

Post by Jeff H »

Ah! Now we're getting somewhere. Yes, I'm on auto updates, but I keep my display on 250% with resolution 2560 x 1600 (100% scaling with that resolution I can't see at all). I noticed that Windows "recommends" a scale of 200%, so I set it to that and the VBE font change worked. I closed Excel, changed the scale back to 250%, reopened Excel and the font had remain 12pts!

Thanks Hans!! :cheers:

- Jeff

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Can't change vba project font size

Post by HansV »

I'm glad it worked!
Best wishes,
Hans

LisaGreen
5StarLounger
Posts: 964
Joined: 08 Nov 2012, 17:54

Re: Can't change vba project font size

Post by LisaGreen »

Nice Tip for the VBE... Thank you!!!!

Lisa

User avatar
Don Wells
5StarLounger
Posts: 689
Joined: 27 Jan 2010, 16:45
Location: Ottawa, Ontario, Canada

Re: Can't change vba project font size

Post by Don Wells »

You saved my bacon again Hans. :thankyou:
Regards
Don

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Can't change vba project font size

Post by HansV »

:thumbup:
Best wishes,
Hans