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.
Bookmarks