jkwleisemann
New Member
- Joined
- May 31, 2016
- Messages
- 19
Not sure if this is a problem with my code, with Win8, with our network, or something else, but I'm having some trouble with the Dir function. Specifically, I'm using the Dir function to try and pull file names from the folder, and the end result is that I can navigate to the folder, but when I try to use the path in the Dir function or when I copy/paste the address in, it fails to open the folder.
Are there some sort of hidden characters or formatting issues that I should be looking for, or is there some sort of issue with the Dir function in Win8?
Here's the code that I'm using, just in case I'm missing something there. But the fact that it happens even when I copy/paste the address into the address bar makes me think that's not it.
Are there some sort of hidden characters or formatting issues that I should be looking for, or is there some sort of issue with the Dir function in Win8?
Here's the code that I'm using, just in case I'm missing something there. But the fact that it happens even when I copy/paste the address into the address bar makes me think that's not it.
Code:
Sub ImportDailyInfo()
datStart = CDate(InputBox(Prompt:="Input start date for input.", Title:="Start Date"))
datEnd = CDate(InputBox(Prompt:="Input end date for import.", Title:="End Date", Default:=datStart))
Do While datEnd < datStart
datEnd = CDate(InputBox(Prompt:="End date must be greater than or equal to the start date." & vbCr & "Input end date for import.", Title:="End Date", Default:=datStart))
Loop
strPath = ThisWorkbook.Path & "\" & Year(Date) & "\" & Month(Date) & " " & Year(Date) & "\DOA Pool Share Sheets\"
For i = Day(datStart) To Day(datEnd)
strFile = Dir(strPath)
strFileChk = WorksheetFunction.Text(Month(datStart), "00") & WorksheetFunction.Text(i, "00") & WorksheetFunction.Text(Year(datStart), "00")
If strFile Like "*" & strFileChk & "*" Then
Workbooks.Open Filename:=strPath & strFile
LoadDOA Workbooks(strFile)
Else
Do While strFile <> ""
strFile = Dir("")
If strFile Like "*" & strFileChk & "*" Then
Workbooks.Open Filename:=strPath & strFile
LoadDOA Workbooks(strFile)
End If
Loop
End If
If strFile <> "" Then Workbooks(strFile).Close
Next
strPath = ThisWorkbook.Path & "\" & Year(Date) & "\" & Month(Date) & " " & Year(Date) & "\SWIB Cash Disbursements\"
For i = Day(datStart) To Day(datEnd)
strFile = Dir(strPath & "*.xls*")
strFileChk = WorksheetFunction.Text(Month(datStart), "00") & "." & WorksheetFunction.Text(i, "00") & "." & WorksheetFunction.Text(Year(datStart), "00")
If strFile Like "*" & strFileChk & "*" Then
Workbooks.Open Filename:=strPath & strFile, Password:="swib1"
LoadSWIB Workbooks(strFile)
Else
Do While strFile <> ""
strFile = Dir("")
If strFile Like "*" & strFileChk & "*" Then
Workbooks.Open Filename:=strPath & strFile, Password:="swib1"
LoadSWIB Workbooks(strFile)
End If
Loop
End If
If strFile <> "" Then Workbooks(strFile).Close
Next
End Sub