Network oddity?

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.

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
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,214,806
Messages
6,121,667
Members
449,045
Latest member
Marcus05

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