此时无法进入休眠模式 [英] Can't enter break mode at this time

查看:178
本文介绍了此时无法进入休眠模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在excel VBA中有sheet.add或sheet.delete时,这种情况越来越多。搜索和搜索后,我终于找到了官方Microsoft 支持页面它。我的问题是,有没有人知道为什么我可以通过这个代码一遍又一遍地完成,然后突然之间,它开始做微软所说的总是这样做,有没有办法解决它? >

This has been happening increasingly, when I have a sheets.add or sheets.delete in excel VBA. After searching and searching I finally found the official Microsoft support page on it. My question is, does anyone know why I could have stepped through this code just fine over and over, and then all of a sudden it starts doing what Microsoft says it would always do, and is there a way to fix it?

Sub foo()

    Sheets.add
    debug.print "sheet added" 'breakpoint here

End sub

这么简单。您将无法重新创建它,因为我问的问题是事实上它不会在最初发生。它工作正常,一遍又一遍地随机呈现在链接的 Microsoft支持页面。

It's as simple as that. You won't be able to recreate it, because the issue I'm asking about is the fact that it doesn't happen at first. It works just fine over and over then randomly presents the error described in the linked Microsoft support page.

推荐答案

这里有一些不是傻瓜的建议,

Here are a few suggestions which are not fool-proof,

首先,验证如果未设置断点,则不会发生错误。

Firstly, verify that the error does not occur if a breakpoint is not set.

如果没有,请尝试其他几个东西:

If it doesn't, try a few other things:


  1. 从VBE Debug菜单编译VBA项目,值得一提。

  2. 完全删除行。运行代码然后把线重新插入,然后用断点再试一次。

  3. Sheets.Add
  4. 之后添加 DoEvents
  5. Debug.Print 之间使用 MsgBox 而不是断点。显示消息框后,尝试使用 ctrl + fn + End 手动中断。 (在这一点上,打破并不是必需的,但是看看你是否可以打破这种方式,这很有趣)

  6. Sheets.Add 实际上,没有理由将断点放在 Print 语句上,如果你可以把它放在上一行。

  7. 有没有Addins?如果是这样,请禁用所有这些,并一次重新启用一个,测试以查看哪个可能会导致错误。

  1. From the VBE Debug menu, "Compile VBA Project", it's worth a shot.
  2. Delete the line entirely. Run the code. Then put the line back in and try again with the breakpoint.
  3. Add a DoEvents statement after the Sheets.Add
  4. Use a MsgBox instead of a breakpoint on a Debug.Print. With the message box displayed, attempt to manually break using ctrl+fn+End. (At this point, "breaking" isn't necessary but it would be interesting to see whether you can break this way)
  5. Put a breakpoint on Sheets.Add instead; practically speaking, there's no reason to put the breakpoint on a Print statement if you can just put it on the preceding line.
  6. Are there any Addins? If so, disable all of them and re-enable one at a time, testing to see which one may contribute to the error.

这篇关于此时无法进入休眠模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆