Excel - import a text file


/ Published in: Visual Basic
Save to your folder(s)



Copy this code and paste it in your HTML
  1. Set shtTmp = Sheets("tmp")
  2. shtTmp.Visible = True
  3. shtTmp.Select
  4.  
  5. With ActiveSheet.QueryTables.Add(Connection:= _
  6. "TEXT;" & Sheets("index").Range("F" & path_loc), _
  7. Destination:=Range("A1"))
  8. .FieldNames = True
  9. .RowNumbers = False
  10. .FillAdjacentFormulas = False
  11. .PreserveFormatting = True
  12. .RefreshOnFileOpen = False
  13. .RefreshStyle = xlInsertDeleteCells
  14. .SavePassword = False
  15. .SaveData = True
  16. .AdjustColumnWidth = True
  17. .RefreshPeriod = 0
  18. .TextFilePromptOnRefresh = False
  19. '.TextFilePlatform = 437
  20. .TextFileStartRow = 1
  21. .TextFileParseType = xlDelimited
  22. .TextFileTextQualifier = xlTextQualifierDoubleQuote
  23. .TextFileConsecutiveDelimiter = False
  24. .TextFileTabDelimiter = True
  25. .TextFileSemicolonDelimiter = False
  26. .TextFileCommaDelimiter = False
  27. .TextFileSpaceDelimiter = False
  28. .TextFileColumnDataTypes = Array(1)
  29. '.TextFileTrailingMinusNumbers = True
  30. .Refresh BackgroundQuery:=False
  31. End With
  32. DoEvents
  33.  
  34.  
  35.  
  36.  
  37. 'clear tmp sheet
  38. shtTmp.Select
  39. Cells.Select
  40. Application.CutCopyMode = False
  41. Selection.Clear
  42. Selection.QueryTable.Delete
  43. shtTmp.Visible = False
  44. Set shtTmp = Nothing

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.