简体   繁体   English

曾经可以使用的Excel VBA公式现在失败

[英]Excel VBA formulas that used to work now failing

I have several small - and a couple larger - macros that I've written to make life easier for myself. 我编写了几个小-几个大-宏,以使自己的生活更轻松。 They've suddenly stopped working. 他们突然停止工作了。 I get the error message: "Compile error: Can't find project or library". 我收到错误消息:“编译错误:找不到项目或库”。 The highlight in debugger points to a simple variable, such as the counter variable in a simple For loop (For i = 1 to 16000) - the i gets highlighted and the error message pops up. 调试器中的突出显示指向简单变量,例如简单的For循环中的计数器变量(对于i = 1至16000)-i被突出显示,并弹出错误消息。

If I declare the variable with "Dim i As Integer", it works just fine. 如果我用“ Dim i As Integer”声明该变量,则它可以正常工作。 But this is new - I've been using this little macro for months without issue. 但这是新的-我使用这个小宏已有几个月没有问题了。 Now this is happening in ALL my macros. 现在,这发生在我所有的宏中。 Was there an update to Excel that I missed? 我错过了Excel的更新吗? Do I now have to specifically declare all my variables (I know this is a best practice, but my macros are personal tools just for me, so I'd like to avoid have to go through a couple dozen macros explicitly declaring variables if at all possible.) 我现在是否必须专门声明所有变量(我知道这是一种最佳做法,但是我的宏只是我的个人工具,因此我想避免不得不通过几个宏来显式声明变量(如果有的话)可能。)

My company uses Office 365, and there was an update not long ago, wondering if that is causing the impact. 我的公司使用Office 365,不久前进行了更新,想知道是否会造成影响。 Is there a reference I need to add? 我需要添加参考吗?

Often when you get the error message "Compile error: Can't find project or library", the issue is that there is a missing reference. 通常,当您收到错误消息“编译错误:找不到项目或库”时,问题是缺少参考。 The website http://www.cpearson.com/excel/missingreferences.aspx has some good information on identifying and troubleshooting this type of situation. 网站http://www.cpearson.com/excel/missingreferences.aspx提供了一些有关识别和排除此类情况的良好信息。

Sharing my recent experience here: this error popped up when opening a complex .xlsb workbook with Power Queries, VBA, and other advanced features. 在这里分享我的最新经验:打开带有Power Queries,VBA和其他高级功能的复杂.xlsb工作簿时,会弹出此错误。 I was getting really frustrated with lack of solutions I found online. 我对在网上找不到解决方案感到非常沮丧。 For example, the MS help file (accessible from help button on error dialog box) pointed to an instruction list for accessing the 'References' dialog in the VB editor and search for 'MISSING' prefix items in the library list. 例如,MS帮助文件(可从错误对话框上的帮助按钮访问)指向用于访问VB编辑器中“参考”对话框并在库列表中搜索“ MISSING”前缀项的指令列表。 For some reason, the References dialog, while not grayed out in the menu, when clicked would pop up a window with gray border and completely transparent box (ie glitched out). 出于某种原因,“参考”对话框在菜单中未显示为灰色,但在单击时会弹出一个带有灰色边框和完全透明的框的窗口(即出现故障)。 I believe it was due to a faulty Office 365 update. 我认为这是由于错误的Office 365更新造成的。 When I had a coworker who is on a different O365 update cycle try to open the file, it worked just fine for her. 当我有一个处于不同O365更新周期的同事尝试打开该文件时,对她来说效果很好。 In addition, she was able to save an exact copy without making any changes. 此外,她无需进行任何更改即可保存精确的副本。 Only then I could then open/edit the file without any error messages or disabled functionality. 只有这样,我才能打开/编辑文件,而不会出现任何错误消息或禁用功能。 Doesn't make a lot of sense. 没什么意义。

Honestly, I used to be excited about rapid release update cycles when Office 365 first came out, but in hindsight they aren't tested very well and often break critical VBA functionality. 老实说,我曾经对Office 365首次发布时的快速发布更新周期感到兴奋,但是事后看来,它们的测试效果不是很好,并且经常破坏关键的VBA功能。 It's a recurring source of frustration for me and my team that are heavy Excel report users and developers. 对于我和我的团队(经常使用大量Excel报表的用户和开发人员),这是令人沮丧的原因。 And I don't have a great preventive solution; 而且我没有很好的预防性解决方案; just got lucky this time that someone else's install didn't have the same problem. 这次很幸运,其他人的安装没有相同的问题。

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

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