VBA:如何使VBE中当前光标跳转到最后发生错误的行?
这仍然与我之前的问题有关, VBA:如何像标准错误消息一样显示带有“调试”按钮的错误消息?
现在,我成功使VBE中的当前光标跳转到VBE中的特定过程。我使用 Application.Goto
来实现这一点。然而,我真正想要的是让VBE中的当前光标跳转到最后发生错误的行。我怀疑 Application.VBE
对象中应该有一些对此目的有用的东西,但不知道是哪个?
解决这个问题也意味着完全满足我之前的问题。有什么提示甚至肮脏的伎俩吗?
This is still related with my previous questions, VBA: How to display an error message just like the standard error message which has a “Debug” button?
Now, I successfully make the current cursor in VBE jump to a particular procedure in VBE. I used Application.Goto
to achieve this. However, what actually I want is to make the current cursor in VBE jump to the line where the last error occured. I suspected there should be something useful for this purpose in Application.VBE
object but didn't know which?
Solving this also means satisfying my previous question entirely. Any hints or even dirty tricks?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
接上一个问题:)
我想您已经在使用行编号(如上一个问题中所回答)。
因此,将错误处理例程修改为如下所示:
现在进行 CodeFind() 操作。我在这里找到了它(在底部,最后一个),但不得不稍微修改一下,所以我发布了很多代码......抱歉。
将此代码插入新模块中,并确保选中了对“Microsoft Visual Basic For Applications Extensibility 5.3”的引用,并且该项目不受保护。如有疑问,请参阅此处。
哈!
这是代码
Continued from your previous question :)
I suppose you are already using line numbering (as answered in the previous question).
So, modify your error handling routine to something like:
Now for the CodeFind() thing. I found it here (at the bottom, the last one), but had to modify it a bit, so I'm posting a lot of code ... sorry.
Insert this code in a new module and be sure you have the reference to "Microsoft Visual Basic For Applications Extensibility 5.3" checked, and the project is not protected. In doubt see here.
HTH!
Here is the code