S
scain2004
I need to code for the possibility that a path was removed from th
system.
If the code is looking for a path that not longer exists, how to I cod
to move past the error and open the dialog?
Code
-------------------
On Error Resume Next
Set wb = Workbooks(cwb)
On Error GoTo 0
If wb Is Nothing Then
If Not GetSetting("PJL", "Startup", "wbPath") = "" Then
Sheets("Admin").Range("CalPath") = GetSetting("PJL", "Startup", "wbPath")
ChDrive Sheets("Admin").Range("CalPath")
ChDir Sheets("Admin").Range("CalPath")
End If
fileName = Application.GetOpenFilename("Excel Files (*.xls),*.xls)", , _
"Please choose a Production Schedule workbook to open")
cwb = ParsePath(fileName, "FILE_ONLY")
wbPath = ParsePath(fileName, "PATH_ONLY")
Sheets("Admin").Range("CalPath") = wbPath
SaveSetting appname:="PJL", section:="Startup", _
key:="wbPath", setting:=wbPath
Sheets("Admin").Range("CalName") = cwb
Set wb = Workbooks.Open(wbPath & cwb)
End If
system.
If the code is looking for a path that not longer exists, how to I cod
to move past the error and open the dialog?
Code
-------------------
On Error Resume Next
Set wb = Workbooks(cwb)
On Error GoTo 0
If wb Is Nothing Then
If Not GetSetting("PJL", "Startup", "wbPath") = "" Then
Sheets("Admin").Range("CalPath") = GetSetting("PJL", "Startup", "wbPath")
ChDrive Sheets("Admin").Range("CalPath")
ChDir Sheets("Admin").Range("CalPath")
End If
fileName = Application.GetOpenFilename("Excel Files (*.xls),*.xls)", , _
"Please choose a Production Schedule workbook to open")
cwb = ParsePath(fileName, "FILE_ONLY")
wbPath = ParsePath(fileName, "PATH_ONLY")
Sheets("Admin").Range("CalPath") = wbPath
SaveSetting appname:="PJL", section:="Startup", _
key:="wbPath", setting:=wbPath
Sheets("Admin").Range("CalName") = cwb
Set wb = Workbooks.Open(wbPath & cwb)
End If