I tried to change the tool. Without luck, could you please indicate where my failure is?
I need the 4,5,6,7 column to be imported as text, otherwise many hexadecimal values โโare converted to scientific ones :)
I used OpenText instead of Open.
Sub TXTconvertXLS2() Dim objExcel As Excel.Application Dim wb As Workbook Dim strFile As String Dim strDir As String Set objExcel = New Excel.Application With objExcel .Visible = False .DisplayAlerts = False End With 'Directories strDir = "c:\temp\" strFile = Dir(strDir & "*.txt") 'Loop Do While strFile <> "" wb = objExcel.Workbooks.OpenText((strDir & strFile), , , xlDelimited, , True, True, , , , , , Array(Array(4, 2), Array(5, 2), Array(6, 1), Array(7, 2)), , , , , "|") With wb .SaveAs Replace(wb.FullName, ".txt", ".xls"), 50 .Close False '<-already saved in the line directly above End With Set wb = Nothing strFile = Dir '<- stuffs the next filename into strFile Loop objExcel.DisplayAlerts = False objExcel.Quit Set objExel = Nothing End Sub
source share