title: Import txt with macro using Excel?
body: <p>i would to import the last modified txt file from a directory using a macro in Excel.
  I have a folder which is incremented everyday by a new txt file.
  The goal is to import the last txt file added in the direrctory.</p>
  
  <p>I've already created a an Excel file with a button affected to macro.</p>
  
  <p>Here is the code of macro:</p>
  
  <pre><code>Sub Import()
  '
  ' Import Macro
  ' Macro saved on 02/03/2011 by StYellowknife3000
  '
  
  '
      With ActiveSheet.QueryTables.Add(Connection:= _
          "TEXT;C:\Folder\File_01.txt", Destination:= _
          Range("A1"))
          .Name = "File_01"
          .FieldNames = True
          .RowNumbers = False
          .FillAdjacentFormulas = False
          .PreserveFormatting = True
          .RefreshOnFileOpen = False
          .RefreshStyle = xlInsertDeleteCells
          .SavePassword = False
          .SaveData = True
          .AdjustColumnWidth = True
          .RefreshPeriod = 0
          .TextFilePromptOnRefresh = False
          .TextFilePlatform = 932
          .TextFileStartRow = 1
          .TextFileParseType = xlDelimited
          .TextFileTextQualifier = xlTextQualifierDoubleQuote
          .TextFileConsecutiveDelimiter = True
          .TextFileTabDelimiter = True
          .TextFileSemicolonDelimiter = False
          .TextFileCommaDelimiter = False
          .TextFileSpaceDelimiter = True
          .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1)
          .TextFileTrailingMinusNumbers = True
          .Refresh BackgroundQuery:=False
      End With
  End Sub
  </code></pre>
  
  <p>Thank you</p>