Results 1 to 6 of 6

Thread: Exporting Excel file items to a text file

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Posts
    5

    Exporting Excel file items to a text file

    Hello Friends,

    I have a Excel file and i need to write a macro to export 1st column fields to a text file in which all the field elements are seperated by coma..could u pl suggest me how to do that, sample code will be helpful

    Thanks

  2. #2
    Hyperactive Member
    Join Date
    May 2003
    Posts
    401
    I made a quick search in this forum. Here are two links that might help u:

    http://www.vbforums.com/showthread.p...le+export+text

    http://www.vbforums.com/showthread.p...l+to+text+file
    Enjoy!!!
    apps_tech

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Posts
    5
    Hello, this is not helping me, could u pl provide the code, what i need to do is copy certain range excel file and paste them in a text file seperated by comas, if i can write a macro that will be very helpful

    Thanks

  4. #4
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697
    Copy the range of data you want to save to a new sheet then use the below.
    Code:
    'Save as a text file
    objExcel.ActiveWorkbook.SaveAs FileName:=C:\Test.txt, FileFormat:=xlText

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Posts
    5
    Using this i am getting object failed error and i do not have help, could u give me the exact code please, thx

  6. #6
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697
    This is to open the spreadsheet.
    Code:
    Dim oXLApp As Object 
    Dim objExcel As Object
    Set objExcel = CreateObject("Excel.Application")
    Set oXLApp = objExcel.Workbooks.Open(FileName:=C:\Book1.xls)
    objExcel.Visible = False 'show excel or not
    objExcel.DisplayAlerts = False
    objExcel.WorkSheets("Sheet1").Select ' Select sheet to work with
    and this is now to save as a txt file.

    Code:
    objExcel.ActiveWorkbook.SaveAs FileName:=C:\Test.txt, FileFormat:=xlText
    HTH

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