标准 VBA 函数的“找不到项目或库”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/507191/
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
"Can't find Project or Library" for standard VBA functions
提问by Adam Davis
So I'm having to run someone else's excel app on my PC, and I'm getting "Can't find Project or Library" on standard functions such as date, format, hex, mid, etc.
因此,我不得不在我的 PC 上运行其他人的 excel 应用程序,并且在日期、格式、十六进制、中位数等标准功能上出现“找不到项目或库”的消息。
Some research indicates that if I prefix these functions with "VBA." as in "VBA.Date" then it'll work fine.
一些研究表明,如果我在这些函数前面加上“VBA”。就像在“VBA.Date”中一样,它会正常工作。
Webpages suggest it has to do with my project references on my system, whereas they must be ok on the developer's system. I'm going to be dealing with this for some time from others, and will be distributing these applications to many others, so I need to understand what's wrong with my excel setup that I need to fix, or what needs to be changed in the xls file so that it'll run on a variety of systems. I'd like to avoid making everyone use "VBA." as an explicit reference, but if there's no ideal solution I suppose that's what we'll have to do.
网页表明它与我系统上的项目引用有关,而它们在开发人员的系统上必须没问题。我将在一段时间内从其他人那里处理这个问题,并将这些应用程序分发给许多其他人,所以我需要了解我需要修复的 excel 设置有什么问题,或者需要在xls 文件,以便它可以在各种系统上运行。我想避免让每个人都使用“VBA”。作为明确的参考,但如果没有理想的解决方案,我想这就是我们必须做的。
- How do I make "VBA." implicit in my project properties/references/etc?
- 我如何制作“VBA”。隐含在我的项目属性/引用/等中?
-Adam
-亚当
采纳答案by Dirk Vollmar
I have seen errors on standard functions if there was a reference to a totally different library missing.
如果缺少对完全不同的库的引用,我会看到标准函数的错误。
In the VBA editor launch the Compile command from the menu and then check the References dialog to see if there is anything missing and if so try to add these libraries.
在 VBA 编辑器中,从菜单中启动 Compile 命令,然后检查 References 对话框以查看是否缺少任何内容,如果有,请尝试添加这些库。
In general it seems to be good practice to compile the complete VBA code and then saving the document before distribution.
一般来说,编译完整的 VBA 代码,然后在分发前保存文档似乎是一种很好的做法。
回答by andres
I had the same problem. This worked for me:
我有同样的问题。这对我有用:
- In VB go to Tools » References
- Uncheck the library "Crystal Analysis Common Controls 1.0". Or any library.
- Just leave these 5 references:
- Visual Basic For Applications (This is the library that defines the VBA language.)
- Microsoft Excel Object Library (This defines all of the elements of Excel.)
- OLE Automation (This specifies the types for linking and embedding documents and for automation of other applications and the "plumbing" of the COM system that Excel uses to communicate with the outside world.)
- Microsoft Office (This defines things that are common to all Office programs such as Command Bars and Command Bar controls.)
- Microsoft Forms 2.0 This is required if you are using a User Form. This library defines things like the user form and the controls that you can place on a form.
- Then Save.
- 在 VB 中转到工具 » 参考
- 取消选中库“Crystal Analysis Common Controls 1.0”。或任何图书馆。
- 只需留下这5个参考:
- Visual Basic For Applications(这是定义 VBA 语言的库。)
- Microsoft Excel 对象库(这定义了 Excel 的所有元素。)
- OLE 自动化(这指定了链接和嵌入文档的类型以及其他应用程序的自动化以及 Excel 用来与外部世界通信的 COM 系统的“管道”。)
- Microsoft Office(这定义了所有 Office 程序的通用内容,例如命令栏和命令栏控件。)
- Microsoft Forms 2.0 如果您使用的是用户表单,则这是必需的。该库定义了诸如用户表单和可以放置在表单上的控件之类的内容。
- 然后保存。
回答by RedBlueThing
I have experienced this exact problem and found, on the users machine, one of the libraries I depended on was marked as "MISSING" in the references dialog. In that case it was some office font library that was available in my version of Office 2007, but not on the client desktop.
我遇到了这个确切的问题,并发现在用户机器上,我依赖的库之一在参考对话框中被标记为“丢失”。在那种情况下,我的 Office 2007 版本中提供了一些 Office 字体库,但在客户端桌面上没有。
The error you get is a complete red herring (as pointed out by divo).
你得到的错误是一个完整的红鲱鱼(正如divo所指出的)。
Fortunately I wasn't using anything from the library, so I was able to remove it from the XLA references entirely. I guess, an extension of divo' suggested best practice would be for testing to check the XLA on all the target Office versions (not a bad idea in any case).
幸运的是,我没有使用库中的任何内容,因此我能够从 XLA 引用中完全删除它。我想,divo 的扩展建议的最佳实践是测试以检查所有目标 Office 版本上的 XLA(在任何情况下都不是坏主意)。
回答by RedBlueThing
In my case, it was that the function was AMBIGUOUS as it was defined in the VBA library (present in my references), and also in the Microsoft Office Object Library (also present). I removed the Microsoft Office Object Library, and voila! No need to use the VBA. prefix.
就我而言,该函数是不确定的,因为它是在 VBA 库(存在于我的参考文献中)和 Microsoft Office 对象库(也存在)中定义的。我删除了 Microsoft Office 对象库,瞧!无需使用 VBA。字首。
回答by Sean McCarthy
In my case, I could not even open "References" in the Visual Basic window. I even tried reinstalling Office 365 and that didn't work. Finally, I tried disabling macros in the "Trust Center" settings. When I restarted Excel, I got the warning message that macros were disabled, and when I clicked on "enable" I no longer got the error message.
就我而言,我什至无法在 Visual Basic 窗口中打开“参考”。我什至尝试重新安装 Office 365,但没有奏效。最后,我尝试在“信任中心”设置中禁用宏。当我重新启动 Excel 时,我收到宏被禁用的警告消息,当我单击“启用”时,我不再收到错误消息。
Later I re-enabled all macros in the "Trust Center" settings, and the error message didn't show up!
后来我重新启用了“信任中心”设置中的所有宏,错误信息没有出现!
Hey, if nothing else works for you, try the above; it worked for me! :)
嘿,如果没有其他方法对您有用,请尝试以上操作;它对我有用!:)
Update:The issue returned, and this is how I "fixed" it the second time:
更新:问题又回来了,这就是我第二次“修复”它的方式:
I opened my workbook in Excel online(Office 365, in the browser, which doesn't support macros anyway), saved it with a new file name (still using .xlsm file extension), and reopened in the desktop software. It worked.
我在Excel Online(Office 365,在浏览器中,无论如何都不支持宏)中打开我的工作簿,使用新文件名(仍然使用 .xlsm 文件扩展名)保存它,然后在桌面软件中重新打开。有效。
回答by SmrtGrunt quit because Monica
In my case I was checking work done on my office computer (with Visio installed) at home (no Visio). Even though VBA appeared to be getting hung up on simple default functions, the problem was that I had references to the Visio libraries still active.
就我而言,我正在家里(没有 Visio)检查在我的办公室计算机(安装了 Visio)上完成的工作。尽管 VBA 似乎被简单的默认函数所困扰,但问题是我对 Visio 库的引用仍然处于活动状态。
回答by Daniel baker
I found references to an AVAYA/CMS programme file? Totally random, this was in MS Access, nothing to do with AVAYA. I do have AVAYA on my PC, and others don't, so this explains why it worked on my machine and not others - but not how Access got linked to AVAYA. Anyway - I just unchecked the reference and that seems to have fixed the problem
我找到了对 AVAYA/CMS 程序文件的引用?完全随机,这是在 MS Access 中,与 AVAYA 无关。我的 PC 上确实有 AVAYA,而其他人没有,所以这解释了为什么它可以在我的机器上而不是其他机器上运行 - 但不能解释 Access 是如何链接到 AVAYA 的。无论如何 - 我只是取消了参考,这似乎解决了问题

