Results 1 to 4 of 4

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

Threaded View

argegg26 Opening TXT files from a list... 10-31-2014, 09:06 AM
Bernie Deitrick Re: Opening TXT files from a... 10-31-2014, 11:28 AM
Tinbendr Re: Opening TXT files from a... 10-31-2014, 11:46 AM
argegg26 Re: Opening TXT files from a... 10-31-2014, 01:25 PM
  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:
    Sub Openfile()
    Set wbk = Workbooks("mainfile.xlsm")
    Dim wkbOne(1 To 7) As Workbook, i As Long 'opens text
    For i = 1 To 7
    
    Set wkbOne(i) = Workbooks.OpenText Filename:=(wbk.Worksheets("Front Sheet").Range("B15").Value & wbk.Worksheets("Front Sheet").Range("g" & i).Value), Origin:=xlMSDOS, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:= _
            Array(Array(0, 1), Array(18, 1), Array(47, 1), Array(63, 1), Array(81, 1), Array(98, 1), _
            Array(113, 1), Array(132, 1)), TrailingMinusNumbers:=True
    
    Next i
    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

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. [SOLVED] 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