R
rsphorler
Always have problems with the error handlers in my macros.
The macro below opens a file then does some other stuff to it but the
error handler does not seem to work and i still get an error if the
file is missing (error 1004 to be precise)
'opens the adjustments file
filepath = ThisWorkbook.Path & "\adjustments.xls"
On Error GoTo nofile1 'specifc error
handler
Workbooks.Open Filename:=filepath 'cause of potential error
On Error GoTo 0 'reset default
error handler
GoTo contadj2
'missing adjustments.xls error handler
nofile1:
On Error GoTo 0
adjust = MsgBox("The Adjustments file is missing, Do you wish to
continue without incorporating any adjustments?", vbYesNo)
If adjust = 6 Then
GoTo contadj2
Else
GoTo abortend
End If
contadj2:
REST OF MACRO
abortend:
end sub
Any ideas why it does not work, or many of the other handlers which
are similar in nature?
Thanks in advance
Richard
The macro below opens a file then does some other stuff to it but the
error handler does not seem to work and i still get an error if the
file is missing (error 1004 to be precise)
'opens the adjustments file
filepath = ThisWorkbook.Path & "\adjustments.xls"
On Error GoTo nofile1 'specifc error
handler
Workbooks.Open Filename:=filepath 'cause of potential error
On Error GoTo 0 'reset default
error handler
GoTo contadj2
'missing adjustments.xls error handler
nofile1:
On Error GoTo 0
adjust = MsgBox("The Adjustments file is missing, Do you wish to
continue without incorporating any adjustments?", vbYesNo)
If adjust = 6 Then
GoTo contadj2
Else
GoTo abortend
End If
contadj2:
REST OF MACRO
abortend:
end sub
Any ideas why it does not work, or many of the other handlers which
are similar in nature?
Thanks in advance
Richard