简体   繁体   English

Excel VBA App自发停止,并显示消息“代码执行已暂停”

[英]Excel VBA App stops spontaneously with message “Code execution has been halted”

I have exactly the problem described here: 我确切地描述了这里的问题

From what I can see on the web, this is a fairly common complaint, but answers seem to be rarer. 从我在网上看到的情况来看,这是相当普遍的投诉,但答案似乎很少。 The problem is this: We have a number of Excel VBA apps which work perfectly on a number of users' machines. 问题是这样的:我们有许多Excel VBA应用程序,它们可以在许多用户的计算机上完美运行。 However on one machine they stop on certain lines of code. 但是,在一台机器上,它们停在某些代码行上。 It is always the same lines, but those lines seem to have nothing in common with one another. 总是相同的线,但是这些线似乎没有任何共同点。 If you press F5 (run) after the halt, the app continues, so it's almost like a break point has been added. 如果在暂停后按F5(运行),该应用程序将继续运行,因此几乎就像已添加了一个断点。 We've tried selecting 'remove all breaks' from the menu and even adding a break and removing it again. 我们尝试从菜单中选择“删除所有休息时间”,甚至添加一个休息时间并再次将其删除。 We've had this issue with single apps before and we've 'bodged' it by cutting code out of modules, compiling and then pasting it back in etc. The problem now seems to relate to Excel itself rather than a single .xls, so we're a little unsure how to manage this. 我们以前在单个应用程序中就遇到过这个问题,我们通过从模块中剪切代码,进行编译然后将其粘贴回等方式来“合并”它。现在的问题似乎与Excel本身有关,而不是单个.xls,所以我们有点不确定如何管理它。

I have managed to resolve it with the accepted answer, but now, when I send the VBA file to my colleagues, they have the same problem. 我已经设法用可接受的答案解决了这个问题,但是现在,当我将VBA文件发送给同事时,他们也遇到了同样的问题。

My question and my problem is - any ideas what to do, as far as it is really not a good idea to go to everyone and to debug every time. 我的问题和我的问题是-任何想法该怎么做,但实际上去每个人并每次调试都不是一个好主意。 And I somehow do not want to add Application.EnableCancelKey = xlDisabled to my macros. 而且我不希望将Application.EnableCancelKey = xlDisabled添加到我的宏中。

Sounds like a ghost break. 听起来像是幽灵般的休息。 File saved one time with a break in there. 文件保存了一次,其中有一个中断。 What has worked for me in the past was to remove any breaks you see and manually step through the code (F8) through completion and then save file. 过去对我有用的是删除您看到的所有中断,并手动完成代码(F8),直到完成,然后保存文件。 Prob now necessay to step all the way through but I like to know I went all the way and didn't miss any. 现在,Prob必须全程通过,但我想知道自己一直走着,没有错过任何机会。

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

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