Why does the VBA IDE's Intellisense in Microsoft Word 2007 keep on changing the case of the name of a particular variable type?

妖精的绣舞 提交于 2019-12-10 03:39:50

问题


This is the most bizarre question I've ever asked. I'm not even sure how to phrase it. I remember something like this happening way back in the VB6 IDE, but I've forgotten the fix. If this is the case, then this is a really old bug in the VB IDE.

Here's the problem:

I'm writing a simple MS Word macro when I accidently typed:

Dim cell as Cell

This activated the dreaded IDE bug. Now, no matter what I do; remove the module, edit it outside the IDE or whatever, the IDE's intellisense formats the variable type "Cell" as "cell"

If I name a new variable:

Dim tcell as Cell

The IDE changes it to:

Dim tcell As cell

This infuriates me to no end. I've tried everything to no avail. This happens even if I edit the module file (.bas) outside of the IDE and reimport it back.

How can I stop this madness?

Updated

Apparently this behavior is not a bug, but by design. See answer.


回答1:


Try putting a

Dim Cell as Cell

somewhere, then delete it and try again... I seem to recall that variable declarations take precedence in setting the casing, thus this should force the casing back to how it should be...




回答2:


VB/VBA variable names are not case sensitive so cell and Cell are the same. I would suggest you name your variables something else - I personally use a letter in front: e.g.

Dim sString as String 's for string
Dim iInt as Integer 'i for integer
Dim oCell as Cell 'o for objects

Hope this helps



来源:https://stackoverflow.com/questions/6212042/why-does-the-vba-ides-intellisense-in-microsoft-word-2007-keep-on-changing-the

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!