Results 1 to 6 of 6

Thread: [RESOLVED] importing data from a txt file

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2009
    Posts
    3

    Resolved [RESOLVED] importing data from a txt file

    newbie -- thanks for your help and your patience -- have a spreadsheet -- now i am importing 12 txt files of data -- 5 lines of header -- 100 rows X 6 columns of numbers -- saved as tab delimited -- i use txt import functions of xcel -- would like to automate the process -- select a file from a pop down menu and import the entire file immediately -- can get to the file (File = Application.GetOpenFilename())
    but don't see how to accomplish the import --

    many thanks

  2. #2

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2009
    Posts
    3

    Re: importing data from a txt file

    thanks for your reply --

    yes -- from an xcel worksheet -- i'd like to click a button -- browse to the txt file -- select -- open -- and have it read in --
    the complete file starting in cell A1 of the worksheet --

    if you can point me to a document / book / etc -- i'd be glad to do the legwork -- just don't know where to start --
    haven't had much luck blindly searching -- perhaps because i really don't know exactly what i am looking for --
    Last edited by ltbme; Jul 19th, 2009 at 06:29 PM. Reason: adding thought

  4. #4

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: importing data from a txt file

    You can use the OpenText function passing the tab delimiter argument...

    Code:
    Dim sFile As String
    sFile = Application.GetOpenFilename("Tab Delimited Text Files (*.txt),*.txt", 1, "Select Tab Delimited Text File...")
    If Len(sFile) <> 0 Then
        Application.Workbooks.OpenText Filename:=sFile, Origin:=xlMSDOS, DataType:=xlDelimited, Tab:=True
    End If
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    New Member
    Join Date
    Jul 2009
    Posts
    3

    Re: importing data from a txt file

    robdog888 -- many thanks -- worked like a charm -- now i need to figure out how to insert the txt file into the existing worksheet at a specific cell -- let me work on that a while and then i'll holler for help in another thread --

Posting Permissions

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



Click Here to Expand Forum to Full Width