Originally posted by SkiNLaB
wow this MZtools is everything i ever dreamed of, and more!

so a big BUMP to this thread for every1 out there
Here is an error handler I Set up in the mztoolz options dialog
i use it with the function to write errors to the logfile (See below)

If you add the header and footer to every new function before
you begin coding in it then you will have automatic error logging setup in one click of the button..

However you should change the error logfile location to your parameters. I have a global variable (GlbStrLogFileName ) which
is stored in the registry set to ......
"C:\WebEmailorderDB\vbproject\newlog.alg"
YOu can name your file what ever you want.

i have a setup panel in my proggies options dialog which looks like this.....





1. Click on the button at the end of the mztoolbar
2. Choose error handler and delete what is in the window then
paste in the following

Start copy below
VB Code:
  1. On Error GoTo {PROCEDURE_NAME}_Error
  2.  
  3.     {PROCEDURE_BODY}
  4. Exit_{PROCEDURE_NAME}:
  5.  
  6.    Exit {PROCEDURE_TYPE}
  7.  
  8. {PROCEDURE_NAME}_Error:
  9.  
  10.    MsgBox _
  11.         "Error " & Err.Number & " (" & Err.Description & ") has occured " _
  12.         & vbCrLf & "in the {PROCEDURE_NAME} procedure of {MODULE_TYPE} {MODULE_NAME}" _
  13.         & vbCrLf & " in the interests of making the program bug free" _
  14.         & " Please Email Software support at [email][email protected][/email]" _
  15.         , vbExclamation, "Please Write Down This Error Message!"
  16.  WriteError Err.Number, Erl, Err.Description, "{MODULE_NAME} {MODULE_TYPE}", "{PROCEDURE_NAME}"
  17.  
  18. resume Exit_{PROCEDURE_NAME}
end copy


An example of how to use/call the error logging
function "WriteError"

VB Code:
  1. '---------------------------------------------------------------------------------------
  2. ' Procedure : mnuSend_Click
  3. ' DateTime  : 10/20/2003 12:07
  4. ' Author    : Steve
  5. ' Purpose   : Displays a test email
  6. '---------------------------------------------------------------------------------------
  7. Private Sub mnuSend_Click()
  8.        'These must be initialized before anything else is tested or
  9.              'errors will result.
  10.        Dim appOL As Outlook.Application
  11.        Dim NewEmail As Outlook.MailItem
  12. 10       On Error GoTo mnuSend_Click_Error
  13.  
  14. 20     Screen.MousePointer = vbHourglass
  15.          
  16.               ' The following code reads a text file and uses that for the body of the email
  17.               ' It then sends an email as an Outlook MailItem
  18.              
  19.            'I deliberately didn't include the TextFileToString_FX file
  20.             'function in this post.
  21.              
  22.               ' Instantiate the Outlook and Mail Item objects
  23.               ' You will need a reference to Outlook 9 or 10 libraries.
  24.              
  25. 30            Set appOL = Outlook.Application
  26. 40            Set NewEmail = appOL.CreateItem(olMailItem)
  27. 50            With NewEmail
  28.              
  29. 60            .To = DefEmailAddress
  30.               'default address if any
  31.              
  32.               'default subject
  33. 70            .Subject = DefEmailSubject
  34.              
  35.               ' Now open a text file and reads its contents for inclusion in the email
  36.              
  37.               'uses default reply template
  38. 80            .Body = TextFileToString_FX(DefEmailTemplate)
  39.              
  40.               ' Display the email so you can ammend details and add your email address.
  41.              
  42. 90            .Display
  43.              
  44.              
  45. 100           Set NewEmail = Nothing
  46. 110           Set appOL = Nothing
  47. 120   Screen.MousePointer = vbDefault
  48. 130           End With
  49. Exit_mnuSend_Click:
  50.  
  51. 140      Exit Sub
  52.  
  53. mnuSend_Click_Error:
  54.  
  55. 150      MsgBox _
  56.               "Error " & Err.Number & " (" & Err.Description & ") has occured " _
  57.               & vbCrLf & "in the mnuSend_Click procedure of Form FrmEmailConfig" _
  58.               & vbCrLf & " in the interests of making the program bug free" _
  59.               & " Please Email Software support at [email][email protected][/email]" _
  60.               , vbExclamation, "Please Write Down This Error Message!"
  61. 160    WriteError Err.Number, Erl, Err.Description, "FrmEmailConfig Form", "mnuSend_Click"
  62.  
  63. 170   Resume Exit_mnuSend_Click
  64. End Sub



See the post below for the output


Paste the following to a Module..


VB Code:
  1. '---------------------------------------------------------------------------------------
  2. ' Procedure : WriteError
  3. ' DateTime  : 10/20/2003 12:34
  4. ' Author    : Steve
  5. ' Purpose   : Send The Error Variables to the log file which will be defined in
  6.             ' GlbStrLogFileName
  7. '---------------------------------------------------------------------------------------
  8. Sub WriteError(LineNum As String, _
  9. errorNum As Integer, _
  10. ErrDesc As String, _
  11. moduleName As String, _
  12. procName As String)
  13.        Dim intVarLen%, strVariable$, I%, aChr As String * 1
  14.         On Error GoTo Err_WriteError
  15.  
  16.             If LogOnOffSetting = 1 Then
  17.                 Dim logFile
  18.                 logFile = FreeFile
  19.                
  20.                 Open GlbStrLogFileName For Append As logFile
  21.                     'write error details to logfile
  22.                      Write #logFile, "If you are reading this file and there are recorded errors in it"
  23.                      Write #logFile, "It does not necessarily mean that the program has bugs in it."
  24.                      Write #logFile, vbCrLf
  25.                      Write #logFile, "The interpretation of this file should be left to Core-Software Support"
  26.                      Write #logFile, "Email this file to [email][email protected][/email] for help."
  27.                      Write #logFile, "or click on the button marked Send Error Log to Support."
  28.                      Write #logFile, "on the Error Logging Tab in the Options Dialog."
  29.                      Write #logFile, "--------------------------------------------------------------"
  30.  
  31.                      Write #logFile, "CoreSoft Web-Mail AutoProcessor Error Log Details Follow"
  32.                      Write #logFile, "--------------------------------------------------------------"
  33.                      Write #logFile, "ModuleName", moduleName$
  34.                      Write #logFile, "Procedure Name", procName$
  35.                      Write #logFile, "Error Number", errorNum%
  36.                      Write #logFile, "Line Number", LineNum$
  37.                      Write #logFile, "Error Text", ErrDesc$
  38.                  
  39.  
  40.                     'write App State to logfile
  41.                     Write #logFile, "DefEmailAddress", DefEmailAddress
  42.                     Write #logFile, "DefEmailSubject", DefEmailSubject
  43.                     Write #logFile, "AutoReplyTemplate", AutoReplyTemplate
  44.                     Write #logFile, "AutoReplySubject", AutoReplySubject
  45.                     Write #logFile, "DefEmailTemplate", DefEmailTemplate
  46.                     Write #logFile, "DefOutLookOrderFolder", DefOutLookOrderFolder
  47.                     Write #logFile, "DefProcessFolder", DefProcessFolder
  48.                     Write #logFile, "DefRepeatFolder", DefRepeatFolder
  49.                     Write #logFile, "DefoutlookFileProcessFolder", DefoutlookFileProcessFolder
  50.                     Write #logFile, "DefOutPutFolder", DefOutPutFolder
  51.                     Write #logFile, "DefFileViewer", DefFileViewer
  52.                     Write #logFile, "DefSMTPServerAddress", DefSMTPServerAddress
  53.                     Write #logFile, "DefServerPort", DefServerPort
  54.                     Write #logFile, "DefServerTimeout", DefServerTimeout
  55.                     Write #logFile, "DefRetAddress", DefRetAddress
  56.                     Write #logFile, "GlbStrReplyHeader", GlbStrReplyHeader
  57.                     Write #logFile, "GlbStrReplyFooter", GlbStrReplyFooter
  58.                     Write #logFile, "OnTopSetting", OnTopSetting
  59.                     Write #logFile, "LogOnOffSetting", LogOnOffSetting
  60.                     Write #logFile, "GlbStrLogFileName", GlbStrLogFileName
  61.                                
  62.                     Write #logFile, "--------------------------------------------------------------------------------------"
  63.  
  64.                 Close logFile
  65.             End If
  66.  
  67. Exit Sub
  68. Err_WriteError:
  69.     MsgBox "Error " & Err.Number & " (" & Err.Description & ") in the EmailErrLog procedure of Module ErrBas", vbExclamation, "Please Write down this message"
  70.     Exit Sub
  71. End Sub



have fun


bindu