+ Reply to Thread
Results 1 to 4 of 4

Opening TXT files from a list Fixed width into Excel and editting them

  1. #1
    Registered User
    Join Date
    03-28-2010
    Location
    wokingham, England
    MS-Off Ver
    Excel 2003
    Posts
    29

    Opening TXT files from a list Fixed width into Excel and editting them

    Hi
    I have been trying to resolve this for a while now.

    I have a spreadsheet with a file path (cell B15) always fixed and a list of text files I need to open in column G (just 7 in the list). The plan is that it opens each individual txt file to the width dimensions specified and then save them with another name. The saving part I can do.

    I am struggling with the loop to open the text file.

    I have written the following code:
    Please Login or Register  to view this content.
    Any help would be greatly appreciated.
    Thanks in advance.
    Last edited by Leith Ross; 10-31-2014 at 01:48 PM. Reason: Added Code Tags

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,987

    Re: Opening TXT files from a list Fixed width into Excel and editting them

    The OpenText method does not return a workbook object, so you need to open the file first and set the object later - and make sure that you have a trailing \ in cell B15 for the path.

    But you really don't need to use an array of workbooks unless you plan on doing something other than saving them.



    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Opening TXT files from a list Fixed width into Excel and editting them

    Please use code tags when posting code.

    Please Login or Register  to view this content.
    David
    (*) Reputation points appreciated.

  4. #4
    Registered User
    Join Date
    03-28-2010
    Location
    wokingham, England
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: Opening TXT files from a list Fixed width into Excel and editting them

    That's fantastic. Thanks for the quick response.

    Apologies. Will use coode tags next time

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Importing fixed width .txt files
    By MarmaladeLover in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-12-2014, 08:41 AM
  2. Macro to import both fixed width and delimited .txt files
    By meng.lee in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-14-2013, 05:37 PM
  3. Import multiple Fixed-Width .txt files into the same worksheet
    By beardo34 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-17-2012, 03:04 PM
  4. Fixed Width Text to Excel with fixed break lines.
    By jameel30 in forum Word Formatting & General
    Replies: 1
    Last Post: 08-10-2012, 08:57 PM
  5. Software to download Fixed Width Files
    By create_share in forum Excel General
    Replies: 1
    Last Post: 12-31-2005, 05:41 PM

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