Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is there a command to get the name of the running procedure?
The reason: My main procedure calls 10 smaller procedures; If any of those 10 procedures throws an error, i want to continue processing and i don't only want to capture the error code and description, but get the name of the procedure where the error occured. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Headly;
Maybe the simplst of things you can do within each of these small procedures is run an error handler with a messagebox !!! -- Regards; Mark Rosenkrantz -- Spreadsheet Solutions Uithoorn Netherlands -- E: W: www.spreadsheetsolutions.nl -- "headly" wrote in message ... Is there a command to get the name of the running procedure? The reason: My main procedure calls 10 smaller procedures; If any of those 10 procedures throws an error, i want to continue processing and i don't only want to capture the error code and description, but get the name of the procedure where the error occured. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I don't know of an automatic way of doing this.
I use a global stack array and line numbers: at the start of each procedure I add the procedure name into the stack array and and at the end of each procedure I remove the procedure name. This allows my error handler to display the call stack, the name of the procedure and the line number. I also have a debug option in the stack handler that shows the procedure calls and levels in the Immediate window. In general this approach seems to work well with a protected XLA. Charles ___________________________________ The Excel Calculation Site http://www.decisionmodels.com "headly" wrote in message ... Is there a command to get the name of the running procedure? The reason: My main procedure calls 10 smaller procedures; If any of those 10 procedures throws an error, i want to continue processing and i don't only want to capture the error code and description, but get the name of the procedure where the error occured. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Not clear on what you mean by "logging to register the processes"; Does each
procedure write to a sheet or metadata that it ran? "Patrick Molloy" wrote: add a new class, call it say clError , then process has an error handler that (1) creates a new clError object and save it to a collection. The clError should contain the details - process name, error number, error message and whatever. the collection should be PUBLIC at the end of the process, you can interrate through the collection or error objects to see what happened. This isn't normal imho. Almost all the investment banks that I work for use logging extensively to register the processes. This makes it easy (readign the text file) to see where the process is, and to review any errors "headly" wrote: The message box stops execution and requires the user to respond; if the process generates 100 errors I can't have someone babysit it for 30-60 minutes and click OK to each message, I just want to continue processing and log errors. "Spreadsheet Solutions" wrote: Headly; Maybe the simplst of things you can do within each of these small procedures is run an error handler with a messagebox !!! -- Regards; Mark Rosenkrantz -- Spreadsheet Solutions Uithoorn Netherlands -- E: W: www.spreadsheetsolutions.nl -- "headly" wrote in message ... Is there a command to get the name of the running procedure? The reason: My main procedure calls 10 smaller procedures; If any of those 10 procedures throws an error, i want to continue processing and i don't only want to capture the error code and description, but get the name of the procedure where the error occured. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
you create a text file called something like
LogFile_20091013.txt you then have a sub that writes to this file eg Sub WriteLog(text) LogTextFile.Write text End Sub the logtextfile sub would open a textstream object to the file, creating it if it doesn't exist, and writes the text to it. The useful thing here is that you can insert the writelog log messages anywhere in the code...so WriteLog "Starting main batch..." WriteLog "Main batch error..." WriteLog "processbname:" & err.description "headly" wrote: Not clear on what you mean by "logging to register the processes"; Does each procedure write to a sheet or metadata that it ran? "Patrick Molloy" wrote: add a new class, call it say clError , then process has an error handler that (1) creates a new clError object and save it to a collection. The clError should contain the details - process name, error number, error message and whatever. the collection should be PUBLIC at the end of the process, you can interrate through the collection or error objects to see what happened. This isn't normal imho. Almost all the investment banks that I work for use logging extensively to register the processes. This makes it easy (readign the text file) to see where the process is, and to review any errors "headly" wrote: The message box stops execution and requires the user to respond; if the process generates 100 errors I can't have someone babysit it for 30-60 minutes and click OK to each message, I just want to continue processing and log errors. "Spreadsheet Solutions" wrote: Headly; Maybe the simplst of things you can do within each of these small procedures is run an error handler with a messagebox !!! -- Regards; Mark Rosenkrantz -- Spreadsheet Solutions Uithoorn Netherlands -- E: W: www.spreadsheetsolutions.nl -- "headly" wrote in message ... Is there a command to get the name of the running procedure? The reason: My main procedure calls 10 smaller procedures; If any of those 10 procedures throws an error, i want to continue processing and i don't only want to capture the error code and description, but get the name of the procedure where the error occured. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Log to a text file like this. strText will hold all the relevant details to
do with the error, such as the name of the procedure, Err.Description and the error line number, Erl. Sub LogData(strFilePath As String, strText As String) Dim hFile As Long On Error GoTo ERROROUT hFile = FreeFile Open strFilePath For Append As #hFile Print #hFile, strText Close hFile ERROROUT: If hFile 0 Then Close hFile End If End Sub RBS "headly" wrote in message ... Is there a command to get the name of the running procedure? The reason: My main procedure calls 10 smaller procedures; If any of those 10 procedures throws an error, i want to continue processing and i don't only want to capture the error code and description, but get the name of the procedure where the error occured. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here's what I use:
http://www.aspfree.com/c/a/Microsoft...VBA-Details/1/ FYI, Application.VBE.ActiveCodePane.CodeModule will give you the name of the module containing the procedure where the error occured. --JP On Oct 13, 9:13*am, headly wrote: Is there a command to get the name of the running procedure? The reason: My main procedure calls 10 smaller procedures; If any of those 10 procedures throws an error, i want to continue processing and i don't only want to capture the error code and description, but get the name of the procedure where the error occured. |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sounds interesting, but where do you download that code from?
RBS "JP" wrote in message ... Here's what I use: http://www.aspfree.com/c/a/Microsoft...VBA-Details/1/ FYI, Application.VBE.ActiveCodePane.CodeModule will give you the name of the module containing the procedure where the error occured. --JP On Oct 13, 9:13 am, headly wrote: Is there a command to get the name of the running procedure? The reason: My main procedure calls 10 smaller procedures; If any of those 10 procedures throws an error, i want to continue processing and i don't only want to capture the error code and description, but get the name of the procedure where the error occured. |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Unfortunately the source code is not provided completely. You'll need
to read that page and apply the concepts to write most of it. I could post what I wrote, if anyone wants to see it. --JP On Oct 13, 5:01*pm, "RB Smissaert" wrote: Sounds interesting, but where do you download that code from? RBS "JP" wrote in message ... Here's what I use: http://www.aspfree.com/c/a/Microsoft...VBA-Details/1/ FYI, Application.VBE.ActiveCodePane.CodeModule will give you the name of the module containing the procedure where the error occured. --JP |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yes, thanks, would be interesting.
RBS "JP" wrote in message ... Unfortunately the source code is not provided completely. You'll need to read that page and apply the concepts to write most of it. I could post what I wrote, if anyone wants to see it. --JP On Oct 13, 5:01 pm, "RB Smissaert" wrote: Sounds interesting, but where do you download that code from? RBS "JP" wrote in message ... Here's what I use: http://www.aspfree.com/c/a/Microsoft...VBA-Details/1/ FYI, Application.VBE.ActiveCodePane.CodeModule will give you the name of the module containing the procedure where the error occured. --JP |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I suggest to log some info and to increase or to decrease the amount of information as far as you need: http://log4vba.everage.ca/ Advantage: With the right level of detail you will even know (even long after somebody has run your app) what your users did when. Disadvantage: Might slow down your app (but - hey, you can switch it off/on whenever you feel the need). Regards, Bernd |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Running a Sub Procedure every 5 seconds | Excel Programming | |||
Running Ontime's procedure while another function is running? | Excel Programming | |||
How to Dim the contents of a variable in running procedure? | Excel Discussion (Misc queries) | |||
Procedure not running automatically... | Excel Programming | |||
Running Userform Procedure | Excel Programming |