R
RobN
I have a procedure, shown below (in part), where I want to jump to another
part of the code when the Directory is invalid. ie I want to be able to run
the code on 3 different computers without having to amend the code each
time. Maybe there's a better way to do this, but I would have thought that
what I have done should work! ie in the part of the code that's headed
'work, if there is no such dir, then the code jumps to the line OFFICE:
without a hitch, BUT even though there is no valid dir in the OFFICE: part
of the code, I get a run-time error 76 "Path not Found" at the line "ChDir
dir", and it doesn't jump to the next part of the code (ie HOME
.
Why doesn't the On Error command work at that point?
If there is a better way to do this please advise.
Rob
Dim drive As String
Dim dir As String
'work
WORK:
On Error GoTo OFFICE
dir = "H:\SupporterStats Construction\"
drive = "H"
ChDir dir
GoTo Proceed
'Office
OFFICE:
On Error GoTo HOME
dir = "K:\2007\common\Supporter Stats\"
drive = "K"
ChDir dir
GoTo Proceed
'home
HOME:
dir = "C:\Documents and Settings\USER\My
Documents\Fola\UnderConstruction\"
drive = "C"
ChDir dir
Proceed:
part of the code when the Directory is invalid. ie I want to be able to run
the code on 3 different computers without having to amend the code each
time. Maybe there's a better way to do this, but I would have thought that
what I have done should work! ie in the part of the code that's headed
'work, if there is no such dir, then the code jumps to the line OFFICE:
without a hitch, BUT even though there is no valid dir in the OFFICE: part
of the code, I get a run-time error 76 "Path not Found" at the line "ChDir
dir", and it doesn't jump to the next part of the code (ie HOME
Why doesn't the On Error command work at that point?
If there is a better way to do this please advise.
Rob
Dim drive As String
Dim dir As String
'work
WORK:
On Error GoTo OFFICE
dir = "H:\SupporterStats Construction\"
drive = "H"
ChDir dir
GoTo Proceed
'Office
OFFICE:
On Error GoTo HOME
dir = "K:\2007\common\Supporter Stats\"
drive = "K"
ChDir dir
GoTo Proceed
'home
HOME:
dir = "C:\Documents and Settings\USER\My
Documents\Fola\UnderConstruction\"
drive = "C"
ChDir dir
Proceed: