I have multiple ascii files in a folder. I want to open each ascii file with delimiter comma, then I want to do some operation and save the file as Excel work book without overwriting the ascii file. Like this need to do for many files ascii file using macro. Anyone help me write excel macro code.
In the loop need to open the ascii file and do the my job then save the file as Excel file in the final folder.then reading next ascii file in the files actually.
But my code is opening the the first ascii file doing the my job, then saving as new Excel file. Instead of opening the next ascii file, it is doing the job on the saved Excel file.
Sub ProcessFiles()
    Dim Filename, Pathname As String
    Dim wb As Workbook
    
    Pathname = ThisWorkbook.path & "\files\"
    Filename = Dir(Pathname)
    Do While Filename <> ""
            
        Call Workbooks.OpenText(Filename:=Pathname & Filename, DataType:=xlDelimited, Comma:=True)
            
        Set wb = ActiveWorkbook
        DoWork wb
                   
        wb.SaveAs Filename:=wb.path & "\final\" & wb.Name & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False, ConflictResolution:=True
        wb.Saved = True
        wb.Close
        'wb.Close SaveChanges:=True
        'Filename = Dir(Pathname & "*.xlsx")
        
    Loop
    
    MsgBox "Successfully Completed. Developed By Siddhu"
    
End Sub
    
Sub DoWork(wb As Workbook)
    With wb
        
       
    myjob goes here in each file      
            
      
    End With
End Sub
 
     
    