Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default knowing error line and module name



i wanna know error line and module name when outbreak of error in any
module.

Sub test()
On Error GoTo erohandle:
~~~~~
~~~~~
Exit Sub
erohandle:
MsgBox "the current module name is " & xxxx & vbCrLf & "the line number
is " & yyyyy
End Sub


*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default knowing error line and module name

look at help on erl - however you have to have explicit line numbers written
into your code (the old Basic way).

Other than that, you will have to code it yourself.

--
Regards,
Tom Ogilvy

"x taol" wrote in message
...


i wanna know error line and module name when outbreak of error in any
module.

Sub test()
On Error GoTo erohandle:
~~~~~
~~~~~
Exit Sub
erohandle:
MsgBox "the current module name is " & xxxx & vbCrLf & "the line number
is " & yyyyy
End Sub


*** Sent via Developersdex http://www.developersdex.com ***



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default knowing error line and module name

There is no automated way, but you could the module name in a constant and
scatter line numbers periodically through the procedure, and then use the
Erl function to get the last line
number encountered before the error was raised. E..g,

Here is an example

Sub TestErrorLineNumber()
Const sModule As String = "Module1"

On Error GoTo ErrHandler:
10:
' some code
20:
' more code
Err.Raise 1
'etc.
Exit Sub
ErrHandler:
MsgBox "Error: " & Err.Number & " " & Err.Description & vbNewLine & _
"in module: " & sModule & " in project: " & Err.Source & vbNewLine &
_
"around the following line: " & Erl
End Sub

You could also add the procedure name.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"x taol" wrote in message
...


i wanna know error line and module name when outbreak of error in any
module.

Sub test()
On Error GoTo erohandle:
~~~~~
~~~~~
Exit Sub
erohandle:
MsgBox "the current module name is " & xxxx & vbCrLf & "the line number
is " & yyyyy
End Sub


*** Sent via Developersdex http://www.developersdex.com ***



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default knowing error line and module name

The MZTools add in is quite useful for this.

There is a routine that add's/removes line numbers to your code, and a
routine that will add an error handler to a module with the name of the
module included automatically.

Robin Hammond
www.enhanceddatasystems.com

"x taol" wrote in message
...


i wanna know error line and module name when outbreak of error in any
module.

Sub test()
On Error GoTo erohandle:
~~~~~
~~~~~
Exit Sub
erohandle:
MsgBox "the current module name is " & xxxx & vbCrLf & "the line number
is " & yyyyy
End Sub


*** Sent via Developersdex http://www.developersdex.com ***



Reply
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
Go to line in Module RB Smissaert Excel Programming 3 February 14th 05 08:28 PM
How do I get rid of "Compile error in hidden module" error message David Excel Discussion (Misc queries) 4 January 21st 05 11:39 PM
Get Module line # for error trapping Geof Wyght[_2_] Excel Programming 5 October 7th 04 01:21 PM
On Error, Capturing current module and actual line of code Paul Martin Excel Programming 4 June 13th 04 06:21 AM
Strange Module line JonWayn Excel Programming 2 November 25th 03 06:02 PM


All times are GMT +1. The time now is 11:24 AM.

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"