PDA

View Full Version : Solved: Where am I in code?



burtburt
08-01-2008, 01:23 PM
Is there a way to determine what the name of the document or subroutine is that is running? In Excel it was ThisWorkbook (I think) that would tell you the name of the book that the code was executing in. What is it in WORD? I want to change from using ActiveDocument when I could have change focus from the document that's executing to something else that is opened or closed programmatically. Even if "ThisDocument" name changes. Also, thought that it could help with error messages so I know where it stopped even without going into the VBE. Could use this to send error reports to me from users when I trap an error.

burtburt
08-01-2008, 02:21 PM
Ok. Solved my own issue again.
"ThisDocument" does work in WORD.

Also for errorhandling "Err.Source" will give you the procedure name.

burtburt
08-01-2008, 03:02 PM
One last little tid bit I just found. When in break mode, you can have a look at all the active procedure calls by using the View>Call Stack dialog box. When you execute a procedure, the procedure name is added to the list in the Call Stack box. If the procedure calls another procedure, it is also added. When each procedure finishes, it's removed in turn from the Call Stack dialog box. Can come in handy but can't be used in code as far as I know.