LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default On Error GoTo

Thank you both for your reply.

"benb" wrote:

I am including my code below. The problem I am having is that it seems if on
execution the code encounters two errors, my second On Error GoTo command
does not work. I am opening two files, and I want the code to prompt the
user for each file's location should it not be able to find them using the
specified path. If it can find one, but not the other (only one error) the
code works fine. But if it can't find either, the first On Error Goto works
while the second does not (I get the standard error message). Why is this?
How can I fix it? (Note: RPTCHANGE is a standard error message for the
program to display in any other circumstances.)

Dim rptFile As String, fileRpt As String

On Error GoTo GETPATH
Workbooks.OpenText Filename:= _
"G:\EMERGING MARKETS\EMST05\Daily P&L\Structured\nycreditdld.txt", _
Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=False, Other:=True, OtherChar:="|", FieldInfo:= _
Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1),
Array(6, 1), Array(7 _
, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1), Array(12,
1), Array(13, 1), Array _
(14, 1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 1),
Array(19, 1), Array(20, 1), _
Array(21, 1))
On Error GoTo RPTCHANGE
GoTo SKIPPATH

GETPATH:
rptFile = Application.GetOpenFilename(Title:="Where's the Oasys report?")
If rptFile = "False" Then
Exit Sub
End If
Workbooks.OpenText Filename:=rptFile1, _
Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=False, Other:=True, OtherChar:="|", FieldInfo:= _
Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1),
Array(6, 1), Array(7 _
, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1), Array(12,
1), Array(13, 1), Array _
(14, 1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 1),
Array(19, 1), Array(20, 1), _
Array(21, 1))
On Error GoTo RPTCHANGE

SKIPPATH: [some other code . . .]

On Error GoTo PATHGET
Workbooks.OpenText Filename:="G:\EMERGING MAKETS\EMST05\Daily
P&L\Structured\frontarenadld.txt", Origin:= _
xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=False, Other:=True, OtherChar:="|", FieldInfo:= _
Array(1, 1)
On Error GoTo RPTCHANGE
GoTo PATHSKIP

PATHGET:
fileRpt = Application.GetOpenFilename(Title:="Where's the Front Arena
report?")
If fileRpt = "False" Then
Exit Sub
End If
Workbooks.OpenText Filename:=fileRpt, Origin:= _
xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=False, Other:=True, OtherChar:="|", FieldInfo:= _
Array(1, 1)
On Error GoTo RPTCHANGE

PATHSKIP: [more code . . . .]

 
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
On Error Goto doesn't goto Paul Excel Programming 1 October 15th 04 03:51 PM
On Error Goto doesn't goto Paul Excel Programming 0 October 15th 04 03:05 PM
On Error GoTo StanJ[_2_] Excel Programming 1 July 31st 04 06:15 PM
On error goto 0? Brian Tozer Excel Programming 10 December 29th 03 09:59 PM
On error goto 0 David Excel Programming 2 November 18th 03 01:43 PM


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