VBA 名稱屬性是否區分大小寫 (Is VBA name property is case sensitive)


問題描述

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 NewAutoUserNick Spreitzer)

參考文件

  1. Is VBA name property is case sensitive (CC BY‑SA 3.0/4.0)

#excel-2007 #excel #vba






相關問題

Excel 2007 - 捕獲打開命令欄按鈕事件 (Excel 2007 - Catch open command bar button event)

將範圍變量傳遞給 Excel 宏中的公式 (Passing Range Variable into formula in Excel Macro)

Formula CONCATENATE (CONCATENATE formulas)

如何使用coldfusion創建xlsx文件 (how to create xlsx files using coldfusion)

Excel匹配兩列並輸出第三個 (Excel match two columns and output third)

Excel 無法將工作表插入到目標工作簿中,因為它包含的行數和 (Excel cannot insert the sheets into the destination workbook, because it contains fewer rows and)

使用多個條件的條件格式 - Excel 2007 (Conditional Formatting using multiple conditions - Excel 2007)

從另一個 Excel 文件更新圖表 (Update chart form another Excel file)

VBA 名稱屬性是否區分大小寫 (Is VBA name property is case sensitive)

將 A1 公式和數組轉換為 L1C1 公式,反之亦然 (convert A1 formula and Array into L1C1 formula and vice-versa)

如何在excel中獲得所需的輸出? (How to get the required output in excel?)

查找包含數字的行中的第一個單元格? (Find first cell in a row that contains a number?)







留言討論