Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Return the Line Number where the Error Occured

Is there a way to return the Line Number where an error occured in a module?

I currently have this and I think it would be useful to know the error
location.

Sub TEST()

On Error GoTo ErrorHandler

Const ModuleName As String = "Module1"
Const SubName As String = "TEST"

' my code here
Exit Sub

'*****************
ErrorHandler:
Call ErrorHandler(ModuleName, SubName, "Error Line Location Here")

End Sub
--
Cheers,
Ryan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Return the Line Number where the Error Occured

You can use "erl" if your code lines are numbered :
14 On Error Resume Next
15 Workbooks.Open "NotAvalidOne.xls"
16 MsgBox Erl
--
Regards.
Daniel
"RyanH" a écrit dans le message de news:
...
Is there a way to return the Line Number where an error occured in a
module?

I currently have this and I think it would be useful to know the error
location.

Sub TEST()

On Error GoTo ErrorHandler

Const ModuleName As String = "Module1"
Const SubName As String = "TEST"

' my code here
Exit Sub

'*****************
ErrorHandler:
Call ErrorHandler(ModuleName, SubName, "Error Line Location Here")

End Sub
--
Cheers,
Ryan



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Return the Line Number where the Error Occured

Just to add to Daniel's response, you don't need to add line numbers to
every line. If you just scatter them every so often, it will report the last
line number it encountered as the offending line. You could then home in on
the actual line.

There is also a free VBE addin, MZ-Tools, that, amongst other things, adds
and removes line numbers to and from your code. You can get it at
http://www.mztools.com/v3/download.aspx

--
__________________________________
HTH

Bob

"Daniel.C" wrote in message
...
You can use "erl" if your code lines are numbered :
14 On Error Resume Next
15 Workbooks.Open "NotAvalidOne.xls"
16 MsgBox Erl
--
Regards.
Daniel
"RyanH" a écrit dans le message de news:
...
Is there a way to return the Line Number where an error occured in a
module?

I currently have this and I think it would be useful to know the error
location.

Sub TEST()

On Error GoTo ErrorHandler

Const ModuleName As String = "Module1"
Const SubName As String = "TEST"

' my code here
Exit Sub

'*****************
ErrorHandler:
Call ErrorHandler(ModuleName, SubName, "Error Line Location Here")

End Sub
--
Cheers,
Ryan





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Return the Line Number where the Error Occured

how do you number your lines?
--
Cheers,
Ryan


"Daniel.C" wrote:

You can use "erl" if your code lines are numbered :
14 On Error Resume Next
15 Workbooks.Open "NotAvalidOne.xls"
16 MsgBox Erl
--
Regards.
Daniel
"RyanH" a écrit dans le message de news:
...
Is there a way to return the Line Number where an error occured in a
module?

I currently have this and I think it would be useful to know the error
location.

Sub TEST()

On Error GoTo ErrorHandler

Const ModuleName As String = "Module1"
Const SubName As String = "TEST"

' my code here
Exit Sub

'*****************
ErrorHandler:
Call ErrorHandler(ModuleName, SubName, "Error Line Location Here")

End Sub
--
Cheers,
Ryan




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Return the Line Number where the Error Occured

Wht is the advantage to having line numbers? Is this the only case you would
need line numbers?
--
Cheers,
Ryan


"Bob Phillips" wrote:

Just to add to Daniel's response, you don't need to add line numbers to
every line. If you just scatter them every so often, it will report the last
line number it encountered as the offending line. You could then home in on
the actual line.

There is also a free VBE addin, MZ-Tools, that, amongst other things, adds
and removes line numbers to and from your code. You can get it at
http://www.mztools.com/v3/download.aspx

--
__________________________________
HTH

Bob

"Daniel.C" wrote in message
...
You can use "erl" if your code lines are numbered :
14 On Error Resume Next
15 Workbooks.Open "NotAvalidOne.xls"
16 MsgBox Erl
--
Regards.
Daniel
"RyanH" a écrit dans le message de news:
...
Is there a way to return the Line Number where an error occured in a
module?

I currently have this and I think it would be useful to know the error
location.

Sub TEST()

On Error GoTo ErrorHandler

Const ModuleName As String = "Module1"
Const SubName As String = "TEST"

' my code here
Exit Sub

'*****************
ErrorHandler:
Call ErrorHandler(ModuleName, SubName, "Error Line Location Here")

End Sub
--
Cheers,
Ryan








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
Unexpected error has occured - AutoRecover has been disabled Hillary Excel Discussion (Misc queries) 1 November 27th 09 05:35 PM
An unavaliable error has occured Robert Excel Discussion (Misc queries) 2 August 26th 09 11:49 PM
Please help me to find out number of column occured pol Excel Discussion (Misc queries) 2 July 17th 09 05:41 PM
Unexpected error occured. - MS Excel Erlington Excel Discussion (Misc queries) 0 June 25th 06 04:30 PM
an error occured initializing the vba libraries 40040 sree Excel Discussion (Misc queries) 0 October 18th 05 07:43 PM


All times are GMT +1. The time now is 07:00 AM.

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

About Us

"It's about Microsoft Excel"