For the sake of simplicity, I have produced a free-standing conversion in Excel.
It works in much the same way as your current Excel application.
However, rather than taking the text file and converting it to Excel, it takes a "new format" text file and converts it to an "old format" text file. This can then be read by the original converter.
Sub EdiConversion()
Dim TxtFile As Variant
Dim TxtFileOut As Variant
Dim EdiRows As String
Dim Edirow As Variant
Dim i As Long
' Ask for the file name that has to be processed
TxtFile = Application.GetOpenFilename("Text Files (*.txt), *.txt")
If TxtFile = False Then
MsgBox "No files selected, nothing to do. Bye."
Exit Sub
End If
' Open the file and read rows processing them one by one
Open TxtFile For Input Access Read As #1
TxtFileOut = Left(TxtFile, Len(TxtFile) - 4) & "_OF.txt"
Open TxtFileOut For Output Access Write As #2
While Not EOF(1)
Line Input #1, EdiRows
Edirow = Split(EdiRows, "'")
For i = LBound(Edirow) To UBound(Edirow)
If Edirow(i) <> "" Then
Print #2, Edirow(i) & "'"
End If
Next i
Wend
Close #1
Close #2
MsgBox "The file has been converted" & vbLf & vbLf & _
"Input: " & TxtFile & vbLf & _
"Output: " & TxtFileOut & vbLf, , _
"Edi File Conversion"
End Sub
It probably wouldn't be too difficult to combine this with the original but I think it's better, at this stage, to "prove the theory" before hacking the original about.
I trust it will help.
Regards
Bookmarks