+ Reply to Thread
Results 1 to 7 of 7

xls to txt converting

  1. #1
    Registered User
    Join Date
    01-24-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    6

    xls to txt converting

    Hi there,

    I am programming a tool in VB.NET which reads a xml file with the inputfile and outputfile arguments and then calls excel to convert the input .xls file to output.txt file. I am not sure how it will work with excel? I am a beginner with excel and dont know how macros work. Please help me what approach should i take and how to use the VBScript in excel?

    Thanks and lot for your help!much appreciated!

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: xls to txt converting

    Hello addictive_mate,

    You mention several different programming languages: VB.net, XML, and VBScript. I am not sure what your question really is as you have not given any details about the Excel workbook.

    If it is a single sheet then you can simply save a copy of the workbook as a CSV or Comma Separated Value file. This is a special type of text file that can be read by Excel and most plain text editors. There are other ways to create text files depending on your conversion needs. It would be beneficial for you to post the workbook you want to convert.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    01-24-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: xls to txt converting

    sorry for the confusion, All iwant is define a macro in a excel workbook which converts the input xls fiel to the output txt file. So basically, my application would call excel from command prompmt withj inputfile and outputfile as arguments and the macro should do the job. Any ideas on how to achieve that?

    Thanks!

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: xls to txt converting

    Hello addictive_mate,

    If the workbook is saved using the CSV method then each sheet becomes a separate text file. If you have more than 1 sheet in the workbook and want the entire workbook saved as a text file then a different method must be employed. To implement an alternative method, it is best to know what the physical layout and format of the file is before coding a solution. This is why I asked you to post the workbook.

  5. #5
    Registered User
    Join Date
    01-24-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: xls to txt converting

    Hi there,

    For test purposes, there would be just one sheet in one workbook to convert.

    Thanks

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: xls to txt converting

    Hello addictive_mate,

    Copy this code to a standard VBA module in the workbook's VBA Project. Change the NewName and FilePath to what you want to use.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-24-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: xls to txt converting

    Hi ther,

    thanks a lot for your help! much appreciated How can I implement this in a way such that I can run it from command line and passt input file and outpur file as parameters? For example

    excel.exe inputfile outputfil?

    Thanks a lot

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1