Below is a code which when run on a PC with excel 2013 brings up and error regarding too many columns/rows for destination sheet. I know this is due to the text file being opened in excel (excel 2013 extension) and then trying to move to the destination sheet which is a .xls file which has a smaller number of rows & columns.
The sheet for now, needs to work on both excel 2007 & 2013 suites.
Is there a way of forcing the text file to be opened into a .xls file format.
I could work around it by saving the newly created file as a .xls format and then re-open it before moving into the destination sheet, but it's bugging me that I cant find a way of doing it without this workaround.
Code:
Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.Delete
Workbooks.OpenText Filename:="P:\pilot\TOIC194.TXT", Origin:=xlWindows, StartRow:=2, DataType:=xlDelimited, TextQualifier:=xlNone, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo:=Array( _
Array(1, 2), Array(2, 2), Array(3, 2), Array(4, 2), Array(5, 2), Array(6, 2), Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1) _
, Array(13, 1), Array(14, 1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 1), Array(22, 1), Array(23, 1), _
Array(24, 1), Array(25, 1), Array(26, 1), Array(27, 1), Array(28, 1), Array(29, 1), Array(30, 1), Array(31, 1), Array(32, 1), Array(33, 1), Array(34, 1), _
Array(35, 1), Array(36, 1), Array(37, 1), Array(38, 1), Array(39, 1), Array(40, 1), Array(41, 1), Array(42, 1), Array(43, 1), Array(44, 1), Array(45, 1), _
Array(46, 1), Array(47, 1), Array(48, 1), Array(49, 1))
Sheets("TOIC194").Select
Sheets("TOIC194").Name = "Sheet1"
Sheets("Sheet1").Move Workbooks("fvd.XLS").Sheets(1)
The sheet for now, needs to work on both excel 2007 & 2013 suites.
Is there a way of forcing the text file to be opened into a .xls file format.
I could work around it by saving the newly created file as a .xls format and then re-open it before moving into the destination sheet, but it's bugging me that I cant find a way of doing it without this workaround.
Code:
Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.Delete
Workbooks.OpenText Filename:="P:\pilot\TOIC194.TXT", Origin:=xlWindows, StartRow:=2, DataType:=xlDelimited, TextQualifier:=xlNone, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo:=Array( _
Array(1, 2), Array(2, 2), Array(3, 2), Array(4, 2), Array(5, 2), Array(6, 2), Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1) _
, Array(13, 1), Array(14, 1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 1), Array(22, 1), Array(23, 1), _
Array(24, 1), Array(25, 1), Array(26, 1), Array(27, 1), Array(28, 1), Array(29, 1), Array(30, 1), Array(31, 1), Array(32, 1), Array(33, 1), Array(34, 1), _
Array(35, 1), Array(36, 1), Array(37, 1), Array(38, 1), Array(39, 1), Array(40, 1), Array(41, 1), Array(42, 1), Array(43, 1), Array(44, 1), Array(45, 1), _
Array(46, 1), Array(47, 1), Array(48, 1), Array(49, 1))
Sheets("TOIC194").Select
Sheets("TOIC194").Name = "Sheet1"
Sheets("Sheet1").Move Workbooks("fvd.XLS").Sheets(1)