简体   繁体   English

VBA名称属性是否区分大小写

[英]Is VBA name property is case sensitive

I have observed that below line of code works on one machine but not on other even though both machines have same office 2007 versions. 我已经观察到,即使两台计算机都具有相同的Office 2007版本,下面的代码行也可以在一台计算机上运行,​​而不能在另一台计算机上运行。

strName = folderObj.Name

But when I convert property from '.Name' to ' .n ame' then it is observed to be working on machine on which it was not working earlier. 但是,当我将属性从'.Name'转换为' .n ame'时,会发现它正在较早无法运行的机器上运行。 Below are some of sample code lines for which I am encountering issues. 以下是我遇到问题的一些示例代码行。 Per my observation where ever earlier I mentioned .Name is failing on another machine: 根据我之前提到的观察,我提到.Name在另一台计算机上失败:

strName = folderObj.Name
Application.ActiveWorkbook.Name

Is there any setting which we may need to perform to ignore case for .name. 是否需要执行任何设置以忽略.name的大小写。

I remember dealing with a very similar issue a while back, but can't remember the specifics. 我记得前一段时间曾处理过一个非常类似的问题,但不记得具体细节。 I want say look for any references in your code to variables, properties, etc that are named 'name' (lower case) and change them to 'Name' (pascal case). 我想说的是查找代码中对名为“名称”(小写)的变量,属性等的任何引用,并将其更改为“名称”(小写字母)。 I have a vague memory of VBA getting confused when you use different casing for items of the same name. 当您对相同名称的项目使用不同的大小写时,我对VBA感到迷惑不解。 (For the lack of a more technical explanation.) I know this doesn't really address the fact that it runs on one computer but not another, but it's worth a look. (由于缺乏更多的技术解释。)我知道这并不能真正解决它在一台计算机上运行但不在另一台计算机上运行的事实,但是值得一看。

Btw, when you say "it's not working" what error are you getting? 顺便说一句,当您说“它不起作用”时,您遇到什么错误?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM