Borders(xlEdgeRight).LineStyle = xlContinuous End With ' If header row, add hard coded row 2 If intRow = 1 Then intRow = intRow + 1 objSheet.Cells(intRow, 1).Value = "Investigation.inv_r_a.true.string" objSheet.Cells(intRow, 2).Value = "Investigation.inv_r_a.true.string" objSheet.Cells(intRow, 3).Value = "Investigation.inv_r_a.false.string" objSheet.Cells(intRow, 4).Value = "Case.inv_w_p.true.date" End If Next End If Next ' Write file and close Excel objExcel.DisplayAlerts = False strOutputFile, cExcel7 False objExcel.Quit Borders(xlEdgeBottom).LineStyle = xlContinuous. Borders(xlEdgeTop).LineStyle = xlContinuous. Borders(xlEdgeLeft).LineStyle = xlContinuous. Font.Bold = True End If ' Borders on all cells. Value = Trim(strToken) ' Bold first row If intRow = 1 Then. ' Define constants Const cExcel7 = 51 Const xlContinuous = 1 Const xlEdgeBottom = 9 Const xlEdgeLeft = 7 Const xlEdgeRight = 10 Const xlEdgeTop = 8 ' Create file system object Set objFSO = CreateObject("Scripting.FilesystemObject") ' Files to work woth strInputFile = objFSO.GetAbsolutePathname("input.txt") strOutputFile = objFSO.GetAbsolutePathname("output.xlsx") ' Read text file into array With objFSO.OpenTextFile(strInputFile, 1) arrInput = Split(.ReadAll, vbNewLine) End With ' Start Excel, create a new worksheet Set objExcel = CreateObject("Excel.Application") objExcel.Visible = False Set objSheet = (1) ' Initialize row index intRow = 0 ' Process each line of input file For Each strInput in arrInput ' Skip all blank lines If strInput "" Then ' Start a new row in Excel, start at first column intRow = intRow + 1 intCol = 0 ' Parse input text line arrTokens = Split(strInput, "|") ' Add each value to Excel sheet For Each strToken In arrTokens intCol = intCol + 1 With objSheet.Cells(intRow, intCol).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |