vba - How can I tell what module my code is executing in? -


For a very long time, when I have an error handler, I get the report whether the project, module , And the process error is thrown inside. I have always completed their name by storing the name through constants. I know that in the class you get a program name with the name TypeMem (May), but obviously only I get one of three pieces of information and when I am not in the "Standard" module.

I have no big problem in using constants, it is just that people do not always keep them up to date, or in return they copy and paste and then you have the wrong name information Is it So what I would do without losing the information, like to get rid of the constants shown in the example, to figure it out.

  Compare options Binary Options Clear Option Base 0 Option Private Module Private Contection m_strModuleName_c as string = "MyModule" Private sub instance () Conflict strProcedureName_c string = "example" error on error Goto Err_Hnd Exit_Proc as: Error resume on sub Err_Hnd Next exit: ErrorHandler.FormattedErrorMessage strProcedureName_c, m_strModuleName_c, _ Err.Description, Err.Source, Err.Number, ARL resume Exit_Proc and sub  

Does anyone say that this is where it said Is? If you can not do this decisively , then the answer is also :)

Edit:
I Also know that the name of the project is in Err.Source. I was hoping to be able to get it without exception for other purposes. If you know great, otherwise we can define that as out of the scope of the question.
I also have information about how to get the error line, but without knowing this information Module.Procedure is certainly useful to some extent. For the project name, the only way I can think of doing this is to deliberately throw any error in some place. Sub head (), and error handling code, resulting in Save Err.Source in a global variable g_sProjectName. Otherwise, I think that a free 3-party DLL called TLBINF32.DLL to remember that did the COM reflection - but it seems like the way to the top for what you want to do, and anybody else Even in the case there is a difference between public and private classes. And finally, you can use a binary editor to search the project name string in your EXE, and then try to read the string from the position. While it is frustrating that the name of each project and code module is built in the EXE, there is no hope of doing it in the way that is happening, it is not recommended.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -