Unable To Open Files With VBA - Unable to find them

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,570
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I am trying to open up a file with this piece of code below...

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.

1684874317509.png


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?
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
In your image i do not see the WSOP 2020 directory in the path line ?
 
Upvote 1
Solution

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top