Q:

Integrate data from several csv files using Dictionary metod

I am trying to integrate data from several csv files using Dictionary approach.
Though path and other details have been checked by me carefully, running of the program is encountering error.

Run-time error 432File name or class name not found during Automation operation.

This error come on the following code line .Item(sn(j)) = GetObject("G:\OF\" & sn(j)).Sheets(1).UsedRange.Value.
Here is my code:
Sub M_integratie_csv()
    sn = Split(CreateObject("WScript.Shell").Exec("cmd /c Dir ""G:\OF\*.csv"" /b").StdOut.ReadAll, vbCrLf)
    With CreateObject("Scripting.Dictionary")
        For j = 0 To UBound(sn)
            .Item(sn(j)) = GetObject("G:\OF\" & sn(j)).Sheets(1).UsedRange.Value
            GetObject("G:\OF\" & sn(j)).Close False
        Next
        Sheets.Add.Name = "total"
        For Each it In .Items
            Sheets("total").Cells(Rows.Count, 1).End(xlUp).Offset(1).Resize(UBound(it), UBound(it, 2)) = it
        Next
    End With
End Sub

Links to csv files used by me are as follows.
     csv file 1
csv file 2
csv file 3
Where it is going wrong?

A:

The following code seems to work just fine on my computer:
Sub M_integratie_csv()
    sn = Split(CreateObject("WScript.Shell").Exec("cmd /c Dir ""G:\OF\*.csv"" /b").StdOut.ReadAll, vbCrLf)
    Set oDic = New Dictionary
    With oDic
        For j = 0 To UBound(sn)
            .Item(sn(j)) = GetObject("G:\OF\" & sn(j)).Sheets(1).UsedRange.Value
            GetObject("G:\OF\" & sn(j)).Close False
        Next
        Sheets.Add.Name = "total"
        For Each it In .Items
            Sheets("total").Cells(Rows.Count, 1).End(xlUp).Offset(1).Resize(UBound(it), UBound(it, 2)) = it
        Next
    End With
End Sub

Note, that the reference to Microsoft Scripting Runtime must be set in the VBE in order for the above code to work.

