This is my exact code with a small change - I have used the VB constants to trap for a Linefeed character, a Carriage Return character or a combination of both.
Use this exact code against your file (after you change the file path name) and try it. Copy it from this page, paste into a module, then create a macro to run this function (sorry if I am telling you something you already know).
The next step is to identify how your file was created so we can check that out, but try this first.
Function TestImport()
Dim strchar As String
Dim strline As String
Dim bolend As Boolean
Dim tst1 As String
Dim tst2 As String
Dim tst3 As String
Dim tst4 As String
Dim tst5 As String
Dim tst6 As String
Dim tst7 As String
Dim tst8 As String
Dim tst9 As String
'Dim strLine2 As String
Dim fp As Integer
Dim strFileName As String
Dim strContinue As String
strContinue = "1rst"
fp = FreeFile()
strFileName = "C:\Data\WESTERN1.txt"
Open strFileName For Input As fp
While Not EOF(fp)
strline = ""
strchar = " "
bolend = False
While Not EOF(fp) And Not bolend
'If Asc(strchar) <> 10 And Asc(strchar) <> 13 And strchar <> vbCrLf Then
If strchar <> vbCr And strchar <> vbLf And strchar <> vbCrLf Then
strchar = Input(1, #fp)
If Not EOF(fp) Then
'If Asc(strchar) <> 10 And Asc(strchar) <> 13 And strchar <> vbCrLf Then
If strchar <> vbCr And strchar <> vbLf And strchar <> vbCrLf Then
strline = strline & strchar
End If
End If
Else
bolend = True
End If
Wend
If Len(strline) = 0 Then GoTo Nextline
'If strContinue = "1rst" Then
tst1 = (Nz(Trim(Mid(strline, 1, 2))))
tst2 = (Nz(Trim(Mid(strline, 3, 11))))
tst3 = (Nz(Trim(Mid(strline, 14, 20))))
tst4 = (Nz(Trim(Mid(strline, 34, 1))))
tst5 = (Nz(Trim(Mid(strline, 35, 1))))
tst6 = (Nz(Trim(Mid(strline, 36, 15))))
tst7 = (Nz(Trim(Mid(strline, 52, 20))))
tst8 = (Nz(Trim(Mid(strline, 71, 3))))
MsgBox tst1
MsgBox tst2
MsgBox tst3
MsgBox tst4
MsgBox tst5
MsgBox tst6
MsgBox tst7
MsgBox tst8
'ElseIf strContinue = "2nd" Then
' tst9 = (Nz(Trim(Mid(strLine2, 1, 2))))
' If tst9 <> "1A" Then
' MsgBox "This will work"
' End If
' MsgBox tst9
'End If
'strContinue = "2nd"
'MsgBox strContinue
'tst9 = (Nz(Trim(Mid(strline, 3, 11))))
'tst10 = (Nz(Trim(Mid(strline, 35, 1))))
'tst11 = (Nz(Trim(Mid(strline, 36, 15))))
'tst12 = (Nz(Trim(Mid(strline, 52, 20))))
'MsgBox tst9
'MsgBox tst10
'MsgBox tst11
'MsgBox tst12
'End If
Nextline:
Wend
Close #fp
End Function