Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,564
- Office Version
- 365
- 2016
- Platform
- Windows
I am trying to open up a file with this piece of code below...
strpath = "D:\WSOP 2020\Distributables\2023\May\24 WED\WS 24-May-23.xlsx"
As you can see from the image, this path and file does exist, yet Excel errs with telling me it can't find the file.
In fact, I can't open any files with this code (although I could earlier before I moved these files to a new thumbdrive)
Any idea why I'm unable to open the files?
VBA Code:
Sub open_data()
Dim dt As String
Dim strmn As String, strsdir As String, strpath As String
Dim day1 As String
Dim day2 As String
Dim it, x As Long
Dim cntdia As Long, cntfld As Long, cntcrt As Long, cnttrl As Long, cntpsv As Long
Dim yr As Double
Dim g As Long, lngt As Long
Dim pn As String, ptype As String
'Stop
Application.ScreenUpdating = False
yr = year(svcDate)
strmn = MonthName(Month(svcDate))
day1 = UCase(Format(svcDate, "ddd"))
day2 = Format(Day(svcDate), "00")
dt = Format(svcDate, "dd-mmm-yy")
strfn = "WS " & dt & ".xlsx"
strsdir = day2 & " " & day1
strpath = "D:\WSOP 2020\Distributables\" & yr & "\" & strmn & "\" & strsdir & "\" & strfn
Workbooks.Open strpath
'... ... ... more code
strpath = "D:\WSOP 2020\Distributables\2023\May\24 WED\WS 24-May-23.xlsx"
As you can see from the image, this path and file does exist, yet Excel errs with telling me it can't find the file.
In fact, I can't open any files with this code (although I could earlier before I moved these files to a new thumbdrive)
Any idea why I'm unable to open the files?