Problems importing a CSV-file

  • Thread starter Thread starter ApPojken
  • Start date Start date
A

ApPojken

Hi!

I have been googleling around for a whole day without coming to
conclusion with this issue.

I am trying to import a CSV-file (semicolon seperated values). I hav
tried and tried with all sollutions I have found but nothing works. I
still imports it with all the semicolons and does not seperate th
fields.

I have tried this:
Workbooks.Open "C:\test\Planner.csv", , , , xlCSV, , , , ";"
this:
Workbooks.Open FileName:=C:\test\Planner.csv, Format:=xlCSV, _
Delimiter:=";", ReadOnly:=True

Neither works. I have also tried to change the ";" to the number fo
semicolon and that didn't work either.

This works:
Shell "Excel.exe " & "C:\test\Planner.csv", vbMinimizedNoFocus
But the problem is when I open the document this way I dont get th
link requiered for my VBA module to work.

Please, please, please help a desperate man!

/Ro
 
Like this?
Workbooks.OpenText "C:\test\Planner.csv", , 1, , , , , True

Still doesn't work
 
Rob,
Excel is taking the value from the Regional Options>Numbers>List Separator
setting.
If this is a ";", the your csv will open as desired. Otherwise, Excel does
not consider the ";" as separating anything.

The alternative is Data>Get External Data>Import File. Record a macro when
you do that, you will something like:

With ActiveSheet.QueryTables.Add(Connection:=
"TEXT;C:\PathToFile\SemiColonSeparatedFile.csv", Destination:=Range("A1"))
'...........
'...........
.TextFileSemicolonDelimiter = True
.TextFileColumnDataTypes = Array(1, 1, ... 1, 1)
End With


NickHK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top