LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
ADK ADK is offline
external usenet poster
 
Posts: 89
Default error handling question

I have numerous macros. I have originally added error handling for each one.
I thought maybe I could reduce my code by making a module for the
error....but the problem is when it goes to that sub, it loses the
Error(Err); Err information ...it only returns a 0

Any ideas on how I can get this to work is it not possible?

Using Excel 2000, vba beginner

Thanks!
----------------------------------------------------------
Example of a macro in my spreadsheet (Sheet1):

Private Sub AboutCommandButton_Click()
On Error GoTo addError
'Workbooks.Open "xxxxxx" 'error testing line - remove first apostrophe
AboutPDSR.Show
Exit Sub
addError:
Call MyErrorRoutine
End Sub


---------------------------------------------------------
My Error module:

Sub MyErrorRoutine()
'Error routine for whole spreadsheet
Dim UserName As String
Dim CpuName As String
Dim WhatOffice As String
Dim MyFullName As String
Dim WorkbookName As String

UserName = Environ("USERNAME")
CpuName = Environ("COMPUTERNAME")
WhatOffice = Environ("USERDOMAIN")
MyFullName = ThisWorkbook.FullName
WorkbookName = Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 4)

Open "P:\PDSR\PDSRlogs\ErrorLog-" & WorkbookName & ".log" For Append As
#2
'Open ThisWorkbook.Path & "\ErrorLog.log" For Append As #2 'Open file
Print #2, Application.Text(Now(), "mm/dd/yyyy HH:mm") _
, UserName, CpuName, WhatOffice, MyFullName _
; Error(Err); Err 'Write data
Close #2 'Close

MsgBox "An error has occurred, contact John Doe (extension 123)"

End Sub

-------------------------------------------------------
The log file report example:

07/17/2007 08:06 doe DMPT04 BNT01
T:\PDSR_Project\PDSR.xls 0

--------------------------------------------------------


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Handling question J@Y Excel Programming 3 June 22nd 07 06:16 PM
Error handling question colofnature[_56_] Excel Programming 0 June 6th 06 05:38 PM
Error handling question sungen99[_114_] Excel Programming 0 June 6th 06 05:28 PM
Look up error handling question. sungen99[_104_] Excel Programming 4 May 12th 06 04:23 PM
question error handling Pierre via OfficeKB.com[_2_] Excel Programming 3 November 7th 05 09:39 PM


All times are GMT +1. The time now is 07:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"