Results 1 to 3 of 3

Import CSV with VBA code fails on 2nd import

Threaded View

ronhb Import CSV with VBA code... 04-02-2013, 09:24 PM
patel45 Re: Import CSV with VBA code... 04-03-2013, 02:27 AM
ronhb Re: Import CSV with VBA code... 04-03-2013, 11:17 PM
  1. #1
    Registered User
    Join Date
    04-02-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    2

    Import CSV with VBA code fails on 2nd import

    I have VBA importing multiple CSV files onto a Sheet using the code below.

    It works on the 1st CSV file imported, but any subsequent files it loads in one column only. The CSV file is ok, since it imports properly manually using Excel's dialog box for importing CSV files.

    Is there a reason why it fails in VBA?

    Thanks,
    Ron
    Here's the code for importing...
    With Worksheets(outSheet).QueryTables.Add(Connection:=connectionName, Destination:=Worksheets(outSheet).Range("A1"))
           .Name = filename
           .FieldNames = False
           .RowNumbers = False
           .FillAdjacentFormulas = False
           .PreserveFormatting = True
           .RefreshOnFileOpen = False
           .RefreshStyle = xlOverwriteCells
           .SavePassword = False
           .SaveData = True
           .AdjustColumnWidth = True
           .RefreshPeriod = 0
           .TextFilePromptOnRefresh = False
           .TextFilePlatform = 437
           .TextFileStartRow = StartRow
           .TextFileParseType = xlDelimited
           .TextFileTextQualifier = xlTextQualifierDoubleQuote
           .TextFileConsecutiveDelimiter = False
           .TextFileTabDelimiter = False
           .TextFileSemicolonDelimiter = False
           .TextFileCommaDelimiter = True
           .TextFileSpaceDelimiter = False
           .Refresh BackgroundQuery:=False
       End With
    Last edited by vlady; 04-02-2013 at 10:57 PM. Reason: code tags

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