+ Reply to Thread
Results 1 to 4 of 4

Import CSV files in macro

  1. #1
    Registered User
    Join Date
    12-03-2014
    Location
    Sherbrooke, Canada
    MS-Off Ver
    Win 2007 + Mac 2011
    Posts
    1

    Question Import CSV files in macro

    I'm using the following code mostly from record activity:

    Please Login or Register  to view this content.
    This code allow me to import CSV files into a specific sheet.

    My problem: It does popup a file dialog box requesting human intervention. That isn't the desired result.

    Solution would be: Load CSV file without user intervention.

    Please help!

  2. #2
    Registered User
    Join Date
    12-09-2014
    Location
    Madison, Alabama
    MS-Off Ver
    2010
    Posts
    3

    Re: Import CSV files in macro

    LucSkywalker - Did you find out how to load a csv file without human intervention. I need this solution as well.

    Brian (WarEagleWisdom)

  3. #3
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: Import CSV files in macro

    Will this not work for what you are trying to do???


    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    12-09-2014
    Location
    Madison, Alabama
    MS-Off Ver
    2010
    Posts
    3

    Re: Import CSV files in macro

    Yes - I did a record and this worked as well

    This macro also uses the ~ as the delimiter.

    Sub Macro1()
    '
    ' Macro1 Macro
    '

    '
    With ActiveSheet.QueryTables.Add(Connection:= _
    "TEXT;C:\Program Files\Siemens\manufdata2014-12-04_15-43-13.csv", Destination _
    :=Range("$A$1"))
    .Name = "manufdata2014-12-04_15-43-13"
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .TextFilePromptOnRefresh = False
    .TextFilePlatform = 437
    .TextFileStartRow = 1
    .TextFileParseType = xlDelimited
    .TextFileTextQualifier = xlTextQualifierDoubleQuote
    .TextFileConsecutiveDelimiter = False
    .TextFileTabDelimiter = True
    .TextFileSemicolonDelimiter = False
    .TextFileCommaDelimiter = False
    .TextFileSpaceDelimiter = False
    .TextFileOtherDelimiter = "~"
    .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1)
    .TextFileTrailingMinusNumbers = True
    .Refresh BackgroundQuery:=False
    End With
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro to Import Multiple TXT Files into workbook - User to select files/directory
    By saber007 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-15-2013, 08:43 PM
  2. Noob 4 Help - Macro to LIST ALL FILES IN FOLDER and then IMPORT ALL LISTED FILES
    By StlSmiln in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-25-2012, 04:02 AM
  3. Macro to import log files with different delimiters
    By DrStrangelove in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-29-2009, 04:53 PM
  4. Import several dat files with macro
    By nilssonn in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-04-2009, 04:16 AM
  5. [SOLVED] Import CSV files using Macro
    By Mintz87 in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 08-29-2005, 05:05 PM

Tags for this Thread

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