Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Error Trapping Still Not Working

In the code below I have extracted all the miscellaneous
lines.

When I run the macro, if the text file that I am trying to
open (F851.txt) does not exist, the macro fails at
the "Workbooks.OpenText...." line. It does not go to
the "Errhandler."

Any ideas why?

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

Sub Payables()

'Turn off warnings, auto recalc, etc.
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayAlerts = False

ChDir "C:\Downloads"

On Error GoTo Errhandler

Workbooks.OpenText Filename:="C:\Downloads\F851.txt",
Origin:=xlWindows, _
StartRow:=4, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, 2), Array(15 _
, 2), Array(25, 2), Array(37, 2), Array(53, 3),
Array(65, 1), Array(71, 1), Array(91, 1), _
Array(111, 1))

End_it:
'Turn on warnings, auto recalc, etc.
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Exit Sub

Errhandler:
MsgBox "Error occured"
Resume End_it

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Error Trapping Still Not Working

It works for me in xl2000 Sr-1. Have you tried to run this
stripped-down version that you posted?

Alan Beban

Ken wrote:

In the code below I have extracted all the miscellaneous
lines.

When I run the macro, if the text file that I am trying to
open (F851.txt) does not exist, the macro fails at
the "Workbooks.OpenText...." line. It does not go to
the "Errhandler."

Any ideas why?

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

Sub Payables()

'Turn off warnings, auto recalc, etc.
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayAlerts = False

ChDir "C:\Downloads"

On Error GoTo Errhandler

Workbooks.OpenText Filename:="C:\Downloads\F851.txt",
Origin:=xlWindows, _
StartRow:=4, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, 2), Array(15 _
, 2), Array(25, 2), Array(37, 2), Array(53, 3),
Array(65, 1), Array(71, 1), Array(91, 1), _
Array(111, 1))

End_it:
'Turn on warnings, auto recalc, etc.
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Exit Sub

Errhandler:
MsgBox "Error occured"
Resume End_it

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Error Trapping Still Not Working

Hi
one idea (as this works for me): In the VBA editor goto 'Tools -
Options - General' and check the setting for 'error interruptions'.
should be the last of the three options

--
Regards
Frank Kabel
Frankfurt, Germany


Ken wrote:
In the code below I have extracted all the miscellaneous
lines.

When I run the macro, if the text file that I am trying to
open (F851.txt) does not exist, the macro fails at
the "Workbooks.OpenText...." line. It does not go to
the "Errhandler."

Any ideas why?

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

Sub Payables()

'Turn off warnings, auto recalc, etc.
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayAlerts = False

ChDir "C:\Downloads"

On Error GoTo Errhandler

Workbooks.OpenText Filename:="C:\Downloads\F851.txt",
Origin:=xlWindows, _
StartRow:=4, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, 2), Array(15 _
, 2), Array(25, 2), Array(37, 2), Array(53, 3),
Array(65, 1), Array(71, 1), Array(91, 1), _
Array(111, 1))

End_it:
'Turn on warnings, auto recalc, etc.
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Exit Sub

Errhandler:
MsgBox "Error occured"
Resume End_it

End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Error Trapping Still Not Working

My bad, sorry.

I had the error trapping option set to "Break on All
Errors."


-----Original Message-----
It works for me in xl2000 Sr-1. Have you tried to run

this
stripped-down version that you posted?

Alan Beban

Ken wrote:

In the code below I have extracted all the

miscellaneous
lines.

When I run the macro, if the text file that I am trying

to
open (F851.txt) does not exist, the macro fails at
the "Workbooks.OpenText...." line. It does not go to
the "Errhandler."

Any ideas why?

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

Sub Payables()

'Turn off warnings, auto recalc, etc.
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayAlerts = False

ChDir "C:\Downloads"

On Error GoTo Errhandler

Workbooks.OpenText

Filename:="C:\Downloads\F851.txt",
Origin:=xlWindows, _
StartRow:=4, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, 2), Array(15 _
, 2), Array(25, 2), Array(37, 2), Array(53, 3),
Array(65, 1), Array(71, 1), Array(91, 1), _
Array(111, 1))

End_it:
'Turn on warnings, auto recalc, etc.
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Exit Sub

Errhandler:
MsgBox "Error occured"
Resume End_it

End Sub

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Error Trapping Still Not Working

I found that out soon after I posted this second plea for
help.

Sorry to take up your time on this one.

Thanks for your patience.

-----Original Message-----
Hi
one idea (as this works for me): In the VBA editor

goto 'Tools -
Options - General' and check the setting for 'error

interruptions'.
should be the last of the three options

--
Regards
Frank Kabel
Frankfurt, Germany


Ken wrote:
In the code below I have extracted all the miscellaneous
lines.

When I run the macro, if the text file that I am trying

to
open (F851.txt) does not exist, the macro fails at
the "Workbooks.OpenText...." line. It does not go to
the "Errhandler."

Any ideas why?

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

Sub Payables()

'Turn off warnings, auto recalc, etc.
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayAlerts = False

ChDir "C:\Downloads"

On Error GoTo Errhandler

Workbooks.OpenText

Filename:="C:\Downloads\F851.txt",
Origin:=xlWindows, _
StartRow:=4, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, 2), Array(15 _
, 2), Array(25, 2), Array(37, 2), Array(53, 3),
Array(65, 1), Array(71, 1), Array(91, 1), _
Array(111, 1))

End_it:
'Turn on warnings, auto recalc, etc.
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Exit Sub

Errhandler:
MsgBox "Error occured"
Resume End_it

End Sub


.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Error Trapping Still Not Working

Hi
no problem :-)
Good it's working now for you.

--
Regards
Frank Kabel
Frankfurt, Germany


Ken wrote:
I found that out soon after I posted this second plea for
help.

Sorry to take up your time on this one.

Thanks for your patience.

-----Original Message-----
Hi
one idea (as this works for me): In the VBA editor

goto 'Tools -
Options - General' and check the setting for 'error interruptions'.
should be the last of the three options

--
Regards
Frank Kabel
Frankfurt, Germany


Ken wrote:
In the code below I have extracted all the miscellaneous
lines.

When I run the macro, if the text file that I am trying to
open (F851.txt) does not exist, the macro fails at
the "Workbooks.OpenText...." line. It does not go to
the "Errhandler."

Any ideas why?

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

Sub Payables()

'Turn off warnings, auto recalc, etc.
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayAlerts = False

ChDir "C:\Downloads"

On Error GoTo Errhandler

Workbooks.OpenText

Filename:="C:\Downloads\F851.txt",
Origin:=xlWindows, _
StartRow:=4, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, 2), Array(15 _
, 2), Array(25, 2), Array(37, 2), Array(53, 3),
Array(65, 1), Array(71, 1), Array(91, 1), _
Array(111, 1))

End_it:
'Turn on warnings, auto recalc, etc.
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Exit Sub

Errhandler:
MsgBox "Error occured"
Resume End_it

End Sub


.

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
Error Trapping from WSH Tom Chau Excel Discussion (Misc queries) 1 August 25th 06 04:21 AM
error trapping flow23 Excel Discussion (Misc queries) 3 April 13th 06 04:51 PM
trapping error RobcPettit Excel Programming 2 January 30th 04 03:37 AM
Error Trapping Neil Excel Programming 1 January 5th 04 04:38 PM
error trapping libby Excel Programming 5 November 25th 03 10:57 PM


All times are GMT +1. The time now is 05:44 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"