Results 1 to 3 of 3

Thread: Import a text file into Excel

  1. #1
    Guest

    Question Import a text file into Excel

    I want to import a text file into Excel. I have a macro in Excel that does it quite well, however I want to handle everyting from VB & not have to have an Excel macrobook with my program. THis is the code I have so far, however, I'm having a problem getting the field_info:= line correct.

    Private Sub Command1_Click()
    Dim objXLApp As Object


    ' Launch Microsoft Excel
    Set objXLApp = CreateObject("Excel.Application")
    objXLApp.Visible = True

    With objXLApp

    Workbooks.Open.Text("C:\WINDOWS\TEMP\MP3_Export.txt", file_origin:=2, start_row:=1, _
    file_type:=1, text_qualifier:=3, consecutive_delim:=False, tab:=True, _
    semicolon:=False, comma:=False, Space:=False, Other:=True, other_char:="-", _
    field_info:=Array(Array(1, 2), Array(2, 2)))
    End With

    End Sub

  2. #2
    New Member
    Join Date
    Sep 2009
    Posts
    3

    Re: Import a text file into Excel

    Hi,
    Did you get the code for importing a text file or data from a text Box into Excel sheet!Please email me at Removed By Mod for the code.I need it urgently!

    Thanks!
    sadzy
    Last edited by Hack; Jan 26th, 2010 at 11:44 AM. Reason: Removed Email Address

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Import a text file into Excel

    You replied to a thread that is over 9 years old and one that doesn't even have a posting member name listed anymore. Given that, I doubt he/she/whoever will be emailing anyone anything.

    In addition, we prefer all answers to questions be publically posted rather than sent via EMail or PM. That way, everyone with a similar problem can benefit.

    Can you import this file manually?

    If so, then start a macro, and do the import. Stop the macro when done, and there is the foundation for your programming code to do it automatically.

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