Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,570
- Office Version
- 365
- 2016
- Platform
- Windows
I am using this code to open a workbook. It first checks to see if such a file exists. If the file exists, it will open it. If it doesn't it will advise the user.
I suspect my error checking code in purple isn't working. When ftr = "May-23 (Tue) schedule_5.xlsx", the error checking line incorrectly identifies the file as existing. There is no file ... there is "May-23 (Tue) schedule_3.xlsx", but not "May-23 (Tue) schedule_5.xlsx". If ftr = "Jan-23 (Wed) schedule_5.xlsx", and there isn't anything remotely close to that in the directory, the error checking code properly identifies it as not existing.
Where have I gone wrong, and what could I do to resolve the unexpected results?
Rich (BB code):
ftr = format(usd, "mmm-dd (ddd)") & " schedule_5.xlsx"
If Dir("U:\PWS\Parks\Parks Operations\Sports\Sports17\DATA\" & ftr) = "" Then
Workbooks.Open Filename:="U:\PWS\Parks\Parks Operations\Sports\Sports17\DATA\" & ftr
Else
ur1 = MsgBox("There is no data file associated with this date." & Chr(13) & "Do you wish to manually enter shift information?", 36, "DATA ERROR")
If ur1 = vbNo Then
uf9_poststaff.MultiPage1.Value = 0
Unload uf9c_idate
Else
MsgBox "FUTURE"
End If
End If
I suspect my error checking code in purple isn't working. When ftr = "May-23 (Tue) schedule_5.xlsx", the error checking line incorrectly identifies the file as existing. There is no file ... there is "May-23 (Tue) schedule_3.xlsx", but not "May-23 (Tue) schedule_5.xlsx". If ftr = "Jan-23 (Wed) schedule_5.xlsx", and there isn't anything remotely close to that in the directory, the error checking code properly identifies it as not existing.
Where have I gone wrong, and what could I do to resolve the unexpected results?
Last edited: