vba 对象“_Application”的方法“Names”失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16174245/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Method 'Names' of object '_Application' failed
提问by user2312119
I am having trouble deploying an Excel 2010 spreadsheet with VBA to a client. They are reporting the following error: "Run-time error '1004': Method 'Names' of object '_Application' failed".
我在将带有 VBA 的 Excel 2010 电子表格部署到客户端时遇到问题。他们报告以下错误:“运行时错误‘1004’:对象‘_Application’的方法‘名称’失败”。
Screenshot
截屏
The relevant portion of code where it is failing is as follows:
代码失败的相关部分如下:
Dim settings as Range
Set settings = Application.Names("basictags").RefersToRange
The name "basictags" definitely exists in the spreadsheet (and it works fine on my end), so I am thinking it has something to do with protected mode being enabled on the client's end. However, they have confirmed that they hit the "enable" button when the protected mode warning is displayed by Excel, so I'm not sure what else could be causing it.
“basictags”这个名字肯定存在于电子表格中(它在我这边工作得很好),所以我认为这与在客户端启用保护模式有关。但是,他们已经确认当 Excel 显示保护模式警告时他们点击了“启用”按钮,所以我不确定还有什么可能导致它。
回答by dotNET
Try Application.ThisWorkbook.Names
instead of Application.Names
.
尝试Application.ThisWorkbook.Names
代替Application.Names
.