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?
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