Run-time error '76':__Path not found

This may be a Windows 7 related problem but I am having difficulty in using the following Macro:

Sub GetCSVFiles()
    FolderName = "C:\Users\Public\Public Documents\SMA\Sunny Explorer\"
    FileType = ".csv"
    Dim fs, f, f1, fc
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(FolderName)
    Set fc = f.Files
    For Each f1 In fc
        If Right(f1, Len(FileType)) = FileType Then
            Workbooks.Open Filename:=f1.Name
        End If
End Sub

Using explorer I can navigate to the folder to see the files I want but I am getting the Run-time error '76'


Alan Cameron

Question Info

Last updated July 15, 2019 Views 9,172 Applies to:

In testit5, you have C:\User (singular) instead of C:\Users (plural). Change that to Users and the code works fine.


Cordially, Chip Pearson Microsoft MVP, Excel Pearson Software Consulting, LLC
Chip Pearson
Excel MVP 1998 - 2014
Pearson Software Consulting, LLC

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.