+ Reply to Thread
Results 1 to 6 of 6

How to: Open file, format data, save file, close file and repeat.

  1. #1
    Registered User
    Join Date
    09-10-2010
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    3

    How to: Open file, format data, save file, close file and repeat.

    Hello everyone,

    I have been given a university project where I need to do a lot of simulations.
    After running these simulations, the outputs I receive are in the form of a text file with the extension ".OUT".
    These outputs are in separate folders, in sets of 20, i.e."...\Set_1\data.OUT", "...\Set_2\data.OUT", "...\Set_3\data.OUT" through to "...\Set_20\data.OUT".

    What I would like to do is:
    1) Open the "data.OUT" text file in the folder "Set_1".
    2) Use the Text to Columns feature of Excel to format a section of the text file into cells.
    3) Save the workbook as "data.xlsx" in the same folder "Set_1".
    4) Close the workbook.
    5) Repeat steps 1 to 4 for the folders "Set_2", "Set_3", ..., "Set_20".

    I have written some code as follows, but I keep receiving errors regarding the "Format" part of the code

    Could someone please assist me?
    Thanks in advance!

    Please Login or Register  to view this content.
    Last edited by thexeber; 09-11-2010 at 12:44 PM. Reason: Problem Solved

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: How to: Open file, format data, save file, close file and repeat.

    Can you post an example .OUT file?
    Martin

  3. #3
    Registered User
    Join Date
    09-10-2010
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: How to: Open file, format data, save file, close file and repeat.

    Sure.

    The forum rules don't allow me to attach files with the extension ".OUT" so I tried saving it as a ".txt" but it is too large for a text file, since it is around ~250kB.
    I have saved the text file as "data.docx", it shouldn't be too much trouble to copy the text from inside the Word document to a text file and save it as "data.OUT".
    Attached Files Attached Files

  4. #4
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: How to: Open file, format data, save file, close file and repeat.

    Several problems here

    Please Login or Register  to view this content.
    is needed because excelapp is an object.

    As you are opening an new instance of Excel, you need to qualify the objects to reference the new instance - otherwise they point at the the objects in the workbook containing the code..

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-10-2010
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: How to: Open file, format data, save file, close file and repeat.

    It works! Thank you so very much mrice You have saved me hours of work.

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: How to: Open file, format data, save file, close file and repeat.

    Please Login or Register  to view this content.



+ 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