問題描述
VBA 名稱屬性是否區分大小寫 (Is VBA name property is case sensitive)
我觀察到下面的代碼行在一台機器上工作,但在另一台機器上卻不行,即使兩台機器都有相同的 office 2007 版本。
strName = folderObj.Name
但是,當我將屬性從 '.Name' 轉換為 '.name' 時,觀察到它正在運行在它之前無法運行的機器上。以下是我遇到問題的一些示例代碼行。根據我的觀察,我之前提到的 .Name 在另一台機器上失敗了:
strName = folderObj.Name
Application.ActiveWorkbook.Name
我們是否需要執行任何設置來忽略 .name 的大小寫。
參考解法
方法 1:
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. (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?
(by NewAutoUser、Nick Spreitzer)