Office VBA Editor not capitalizing some recognized

2019-08-13 02:50发布

I'm getting a strange behavior from the Office VBA Editor: certain terms no longer capitalize when they are recognized. In fact, I can use the autoselect to choose the term, which is properly capitalized until the compiler validates the line and the editor actually changes it to lower case.

For example, today I typed this Set wFramework = application.ActiveWorkbook using the auto-select to choose .ActiveWorkbook, but as soon as I pressed [Enter], the compiler changed it to Set wFramework = Application.activeworkbook. Notice that the compiler properly capitalized Application but improperly removed the capitalization from .activeworkbook.

For now the number of objects / methods that don't capitalize correctly is small, but seems to be growing.

I've tried things like turning off all the code settings in hopes this would somehow reset things, but that was a non-starter. I can't find anywhere with controls for that function. I wondered if this is handled through the References, but there doesn't seem to be anyway those should be editable, especially without my doing it on purpose. I'm also wondering if this is somehow a function of Windows improperly tracking case management, but again it seems like that would be specific to a Windows session, and this symptom persists even if I have shut down the computer completely and restarted.

Does anyone know what might cause this, and whether it is possible to reset?

2条回答
叼着烟拽天下
2楼-- · 2019-08-13 03:20

I had the same behaviour with the Enabled property always being displayed as e.g. chkReportFinance.enabled = False.

This was easily fixed by adding a line Dim Enabled, which capitalised all instances, then removing the line.

查看更多
时光不老,我们不散
3楼-- · 2019-08-13 03:20

Tim Williams said:

"Sometime if you have (eg) defined a variable with the name application then the compiler gets "stuck" on that case and doesn't correct later uses to Application, even after renaming the variable. If the problem persists try exporting and re-importing your code modules (see Rob Bovey's "code cleaner" tool for an easy way to do this: appspro.com/Utilities/CodeCleaner.htm)"

This solved the problem. Question answered!

查看更多
登录 后发表回答