I have a collection of data files that have their own unique layout and are changing constantly
What I was trying to do was to take the layout from the spreadsheet where it defines the record layout and create a string that defines the layout each time. I have another macro that sets up the formula to define each indivdual array (="Array("&D7-1&VLOOKUP(E7,$G$1:$H$5,2,0)). Then VB creates the complete Array by stringing each record together.
MyArray = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
Do Until IsEmpty(ActiveCell.Value)
MyArray = MyArray & "," & ActiveCell.Value
ActiveCell.Offset(1, 0).Select
Loop
MyArray = "Array(" & MyArray & ")"
ActiveCell.Value = MyArray
ActiveCell.Offset(1, 0).Select
Workbooks.OpenText Filename:= _
"\\Path\Filename.txt", Origin:=437, _
StartRow:=1, DataType:=xlFixedWidth, FieldInfo:= "" & MyArray,TrailingMinusNumbers:= True
I get the always helpful Runtime 1004 error saying the method of opening the workbook object has failed.
Can I set the array this way? When I step through and look at the value held in MyArray, it looks fine (albeit a string)
Thanks for your help
Jeff
Bookmarks