ThisWorkbook 中事件 workbook_open 中的 Form Show 方法在焦点上中断
当我尝试在私有子 workbook_open() 内的 ThisWorkbook 中使用 userform1.show 显示 userform1 时,它做了最奇怪的事情。 (我使用的是 Excel 2007)- 它进入中断模式并停止代码的运行!
我打开启用宏的工作簿,用户窗体按计划显示,但是当我在用户窗体区域内移动鼠标时,它会进入中断模式并突出显示 UserForm1.Show 行,就好像这就是问题一样。
此外,当我按 F8 时,它突出显示私有子 workbook_open() ,另一次按再次突出显示 userform1.show ,另一次按向我显示运行时错误“400”。:
应用程序定义或对象定义的错误。
这以前从未发生在我身上,我发现一个帖子说没有答案 此处。
有什么想法吗?
When I try to show userform1 with userform1.show in ThisWorkbook within the private sub workbook_open(), it does the strangest thing. (I'm using Excel 2007)- It enters break mode and stops the running of the code!!!
I open the macro enabled workbook and the userform appears as planned, but the when I move the mouse within the area of the userform it enters break mode and highlighting the row UserForm1.Show as if it is the problem.
Furthermore when I press F8 it's highlighting the private sub workbook_open() and another press highlights userform1.show again and another press shows me the run time error '400'.:
application-defined or object-defined error.
This has never happened to me before, I found a post that says it has no answer here.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我也遇到过同样的场景。
我所做的是将 Form 属性中的 ShowModal 属性更改为 False,然后中断就消失了。
I also came across the same scenario.
What I did was to change the ShowModal property in the Form properties to False and the break went away.
我遇到了同样的问题,上面的答案并没有解决它。重新启动电脑暂时解决了问题,但过了一段时间问题又出现了。经过几天令人沮丧的多次重新启动电脑后,我得出了以下结论:
我认为导致问题的原因是当您在运行时使用 ctrl+break 停止代码时。
对我来说解决问题的方法是在代码未运行时按 ctrl+break,它会显示它处于中断模式,然后按 F5。它不会开始运行,但会再次退出中断模式。完成此操作后,问题应该得到解决,您可以像往常一样运行代码。
我想这个方法的工作原理与重新启动电脑相同,但速度要快得多。
I had the same problem, and the answers above didn't fix it. Restarting the PC resolved it temporarily, but after a while the problem returned. After a few frustrating days with a lot of restarting the pc, I came up with these conclusions:
What I think causes the problem is when you use ctrl+break to stop the code while running.
What solves the problem for me is to press ctrl+break while the code is NOT running, it'll show that it's in break-mode, and then press F5. It won't start running, but it will exit break mode again. When you've done this the problem should be fixed and you can run the code as usual.
I guess this method works the same as restarting your pc, but it's a lot faster.
这是我在开发时已经遇到过的奇怪行为...一些提示可能会帮助您:
if 1 = 2 then DoEvents
) 在“隐藏断点”之前,编译代码,然后再次删除代码无论哪种方式,这对我来说都是一个谜,导致这个奇怪问题的原因。似乎有些断点在删除后仍保留在内存中......
希望有帮助!
It's an odd behaviour I already faced some times when dev'ing... some tips that might help you out:
if 1 = 2 then DoEvents
) before the 'hidden breakpoint', compile the code and then remove the code againEither way, that's a mystery for me the cause of this odd issue. It seems that somehow some breakpoints are kept in the memory even after removing them...
Hope it helps!
首先要尝试的是重新编译 VBA 项目,然后保存包含宏的工作簿。如果编译抛出错误,您可能会从编译器消息中获得更多信息,例如缺少引用。
还要确保清除了所有以前存在的断点。可能的情况是,您首先必须创建一个新断点 (F9),然后清除所有断点 (Ctrl+< kbd>Shift+F9)以启用该命令。
First thing to try is to recompile your VBA project and then save the workbook containing the macro. If compiling throws up an error you will probably get more information from the compiler message such as a missing reference.
Also make sure that you cleared all previously existing breakpoints. It might be the case that you first have to create a new breakpoint (F9) and then clear all breakpoints (Ctrl+Shift+F9) for the command to be enabled.