+ Reply to Thread
Results 1 to 6 of 6

Problems importing a CSV-file

  1. #1
    Registered User
    Join Date
    03-16-2006
    Posts
    3

    Problems importing a CSV-file

    Hi!

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

    I am trying to import a CSV-file (semicolon seperated values). I have tried and tried with all sollutions I have found but nothing works. It still imports it with all the semicolons and does not seperate the 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 for 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 the link requiered for my VBA module to work.

    Please, please, please help a desperate man!

    /Rob

  2. #2
    Ardus Petus
    Guest

    Re: Problems importing a CSV-file

    Try Workbooks.Opentext function

    HTH
    --
    AP

    "ApPojken" <[email protected]> a écrit
    dans le message de
    news:[email protected]...
    >
    > Hi!
    >
    > I have been googleling around for a whole day without coming to a
    > conclusion with this issue.
    >
    > I am trying to import a CSV-file (semicolon seperated values). I have
    > tried and tried with all sollutions I have found but nothing works. It
    > still imports it with all the semicolons and does not seperate the
    > 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 for
    > 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 the
    > link requiered for my VBA module to work.
    >
    > Please, please, please help a desperate man!
    >
    > /Rob
    >
    >
    > --
    > ApPojken
    > ------------------------------------------------------------------------
    > ApPojken's Profile:

    http://www.excelforum.com/member.php...o&userid=32516
    > View this thread: http://www.excelforum.com/showthread...hreadid=523012
    >




  3. #3
    Registered User
    Join Date
    03-16-2006
    Posts
    3
    Like this?
    Workbooks.OpenText "C:\test\Planner.csv", , 1, , , , , True

    Still doesn't work.

  4. #4
    NickHK
    Guest

    Re: Problems importing a CSV-file

    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

    "ApPojken" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi!
    >
    > I have been googleling around for a whole day without coming to a
    > conclusion with this issue.
    >
    > I am trying to import a CSV-file (semicolon seperated values). I have
    > tried and tried with all sollutions I have found but nothing works. It
    > still imports it with all the semicolons and does not seperate the
    > 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 for
    > 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 the
    > link requiered for my VBA module to work.
    >
    > Please, please, please help a desperate man!
    >
    > /Rob
    >
    >
    > --
    > ApPojken
    > ------------------------------------------------------------------------
    > ApPojken's Profile:

    http://www.excelforum.com/member.php...o&userid=32516
    > View this thread: http://www.excelforum.com/showthread...hreadid=523012
    >




  5. #5
    Registered User
    Join Date
    03-16-2006
    Posts
    3
    NickHK - That did the trick! Thanks alot!

  6. #6
    Ardus Petus
    Guest

    Re: Problems importing a CSV-file

    The following works by me:

    Sub readCSV()
    Workbooks.OpenText _
    Filename:="U:\family2.csv", _
    semicolon:=True
    End Sub

    HTH
    --
    AP

    "ApPojken" <[email protected]> a écrit
    dans le message de
    news:[email protected]...
    >
    > Hi!
    >
    > I have been googleling around for a whole day without coming to a
    > conclusion with this issue.
    >
    > I am trying to import a CSV-file (semicolon seperated values). I have
    > tried and tried with all sollutions I have found but nothing works. It
    > still imports it with all the semicolons and does not seperate the
    > 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 for
    > 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 the
    > link requiered for my VBA module to work.
    >
    > Please, please, please help a desperate man!
    >
    > /Rob
    >
    >
    > --
    > ApPojken
    > ------------------------------------------------------------------------
    > ApPojken's Profile:

    http://www.excelforum.com/member.php...o&userid=32516
    > View this thread: http://www.excelforum.com/showthread...hreadid=523012
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1