LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 230
Default On Error not working as I thought

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:


 
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
Don't think it's possible, but I thought I would ask. smaumau Excel Worksheet Functions 1 April 3rd 06 11:20 PM
Simple Formula (I thought) csandi Excel Worksheet Functions 3 November 14th 05 08:47 PM
I THOUGHT I knew what I was doing RJB Charts and Charting in Excel 7 September 12th 05 08:37 PM
This is A LOT harder than I thought it would be Robert Excel Discussion (Misc queries) 13 August 24th 05 12:20 AM
On second thought ... Jerry Kinder New Users to Excel 0 November 26th 04 02:38 AM


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