+ Reply to Thread
Results 1 to 15 of 15

Error execution Report

  1. #1
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Error execution Report

    Hi guys,

    What i'm trying to do is to have an error report when i execute my macro, i have a problem with my error report, in fact what i need to do is an inputbox where i can put the name of my Macro to execute: "Module1.MacroName" but the problem is that when i want to execute my macro it doesn't work.
    here's the code:

    Please Login or Register  to view this content.
    I don't know where is the problem i have in the beginnig of the Macro: On Error GoTo analyse but when it enter in Test this dosen't work.

    Does anyone knows how to solve this problem please.

    Thanks for your help
    Last edited by pierre08; 05-28-2010 at 05:55 AM.

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Poblem with an Error execution Report

    We always need more information than "doesn't work". In what way? Errors? Does the wrong thing? Does nothing?

    As an aside, you should not use On Error Goto like that - if an error occurs anywhere after your analyse: label, it will cause a run time error.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Poblem with an Error execution Report

    I would prefer:

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Re: Poblem with an Error execution Report

    your right snb i forgot to extract just the module name to put numbers to the lines.

    But my real problem is when i execute the macro "GestionErreur", what i need to do is execute my macro "test" from "GestionErreur" and have the error Report of the execution of "test" if there is some errors.
    For that i've used at the begining of the macro "GestionErreur":
    Please Login or Register  to view this content.
    and then:
    Please Login or Register  to view this content.
    but the problem is if it find an error in the macro test it show an message error in steed of going to analyse.


    Please Login or Register  to view this content.
    I hope that it quite clear, if anyone knows where is the error or what should i change is my code i'll be gratful.

    Thanks for your help.

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Poblem with an Error execution Report

    first another improvement of your code

    instead of:
    Please Login or Register  to view this content.
    use
    Please Login or Register  to view this content.
    I fear that what you want to accomplish you can't.
    suppose you call a macro: par example Sub tst()
    if an error occurs then the code in 'tst' will return to the 'calling' macro.
    In the macro Sub tst() there is a line 'On error resume next'.
    The error number (err.number) will not be stored in a variable, and as soon as this macro finishes err.number is being reset (let alone that no information is available in which codeline the error took place.)
    So after returning in the 'calling' macro no information is available on what happened in the macro 'tst'.
    The best you could do is putting the err.number in macro 'tst' in a public variable, so that you can analyse the generated code in the calling macro, using the public variable.

    I have no problems using this code:

    Please Login or Register  to view this content.
    prerequisite:
    - sub test is a public macro
    - if sub test is part of a sheetmodule you have to enter in the inputbox feuille1.test
    - if sub test is part of the workbookmodule you have to enter in the inputbox Thisworkbook.test
    Last edited by snb; 05-26-2010 at 04:57 AM.

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Poblem with an Error execution Report

    As I mentioned earlier, if you use On Error Goto the way you are (i.e. without a Resume statement), then everything after your analyse: label is actually an error handler block, and if an error occurs in an error handler block, you get a run-time error.

  7. #7
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Re: Poblem with an Error execution Report

    Is there a solution for that please or is there another way to do this???

    Please help i need this.

    Thanks for your help

  8. #8
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Error execution Report

    The combination Inputbox/application Run isn't a problem.

    What you want to achieve (a debugging tool) is.
    But there is a bunch of debugging tools in the VBEditor.(you don't have to invent what is already built-in.)

  9. #9
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Error execution Report

    The issue is the fact you are using Run. When you do that, errors in the called routine are not handled by an error handler in the calling routine.

  10. #10
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Re: Error execution Report

    In fact what i need to do is execute the hole code and if it find an error to write the line, the number and the description of the error and continu its execution of the code, this way i can have a report at the end because i have some macros that need many hours to finish there execution so usually i execute them at night so in the morning they are done and in case there are some errors it continu its execution in steed of stoping.

    What i tried to do with this code is in steed of puting:

    Please Login or Register  to view this content.
    I made a macro that copy the code of the macro that i need to execute in the error handler, but the problem is that if i execute the code step by step it work and if i execute the hole code it give me an excel error and it restart excel.

    I'll join the workbook for you to see.
    In the module CopierUnModule i execute the last macro: "GestionErreurFinale"
    this macro create the module "GestionErreur1" and if i execute this module i get an excel error but if i take out the macro that give number to all the lines and execute it first and then execute the code it works.

    I don't know if i was clear in all what i've said.
    If you have some question just let me know.
    Thanks for your help
    Attached Files Attached Files

  11. #11
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Error execution Report

    You should have one error logging routine that you call from each of your macros, not the other way round (which makes no sense to me at all).

  12. #12
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Re: Error execution Report

    Do you have an exemple for that please.
    It's almost a week that i'm working on this macro so i'll almost give up on this.

    Thanks for your help.

  13. #13
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Error execution Report

    Something like this (untested):
    Please Login or Register  to view this content.
    then in your test routine:
    Please Login or Register  to view this content.

  14. #14
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Error execution Report

    I'd say

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  15. #15
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Re: Error execution Report

    I can't thank you enough it finally works

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1