VBA Error trapping question

naverty

Registered User.
Local time
Today, 23:46
Joined
Dec 1, 2004
Messages
10
Hi,

When an error occurs I use the VBA error trapping to log the name of the screen, the user, the error number and the error description in a table. Is it possible to dump the local variables (f.i. as seen in the Locals Window) as well ?
Can this be done with VBA or with an API ?
 
Hi,

When an error occurs I use the VBA error trapping to log the name of the screen, the user, the error number and the error description in a table. Is it possible to dump the local variables (f.i. as seen in the Locals Window) as well ?
Can this be done with VBA or with an API ?

I'm gonna go out on a limb and say I don't think there is a way. The only thing I've ever found that's close is the API ReadProcessMemory, but this requires a handle to the current process, which can be obtained via another API, and then a handle to where the variable resides in memory which can be obtained using one of the xxxPtr functions (i.e. StrPtr, IntPtr, VarPtr). The bottom line is you would need to do it for every variable you're using so at that point you could just debug.print them or write them to a file.

If anyone has a solution for this that works please post it as I'm also interested in this.
 
If the trap is local to the module incurring the trap, it has the same scope as the local variables. If not, it doesn't.

Solution? For debugging purposes, move all items of interest to the declaration area of your general module or class module and let the traps see everything there.
 

Users who are viewing this thread

Back
Top Bottom