Microsoft Visual Basic can't access a .csv file - why? How to fix?

fred3

New Member
Joined
May 1, 2011
Messages
39
In the past, I was able to open downloaded .csv files using:
VBA Code:
With TempSheet.QueryTables.Add(Connection:="TEXT;" & savePath, Destination:=TempSheet.Range("A1"))
            .TextFileParseType = xlDelimited
            .TextFileCommaDelimiter = True
            .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1)
            .Refresh
        End With
But, now, when it hits .Refresh, I get this MSVB Run-time error:
1696182181193.png


I'm struggling with finding out what's causing it.

I have compared older .csv files with more recent ones and the only difference is the first column (a date) format YYYY-MM-DD vs. MM/DD/YYY and nothing else (usng Notepad++).
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Instead of VBA, Excel since 2010 version has Power Query which allows you to import .CSV files directly without any coding.

 
Upvote 0
Alan,
That's very interesting! So, might that help here?
I have a VBA system that gets updated frequently. A .csv file is downloaded and saved.
(There is very little sheet interaction).
Then there is an update to the system with that new data from the CSV where it is brought into a sheet - much like you have shown.
If a new .csv is downloaded then am I to understand that the sheet can be updated automatically?

Thanks!
 
Upvote 0

Forum statistics

Threads
1,215,087
Messages
6,123,050
Members
449,092
Latest member
ikke

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