Hi
This is a very similar question to one which I and others have already given you a similar answer many, many times
Here just a few examples :
https://excelfox.com/forum/showthrea...ge28#post13208 b
https://eileenslounge.com/viewtopic....269104#p269104

Never mind.



Text files can take many different forms. You should know this already.
Here, https://excelfox.com/forum/showthrea...ge30#post13348 , I have looked at your latest text file , Alert..txt , in detail.
I have done the same many times for you before.
Your latest text file , Alert..txt , in this thread is a bit unusual, as it has a vbLf as the line ( record ) separator.




This macro does what I think you are asking for.
Note: We are not really converting data from .xlsx to .txt file.
We are making a text file that uses commas , as the values separator, and vbLf as the line ( record ) separator

Code:
' https://excelfox.com/forum/showthread.php/2518-convert-the-data-from-xlsx-to-txt-file
Sub xlsxTotxt_LineSeperatorvbLf_valuesSeperatorComma()
Rem 1 Workbooks info
Dim Wb1 As Workbook: Set Wb1 = Workbooks("sample2.xlsx")
Dim Ws1 As Worksheet: Set Ws1 = Wb1.Worksheets.Item(1)
Dim Lr As Long, Lc As Long
 Let Lr = Ws1.Cells.Range("A" & Ws1.Rows.Count & "").End(xlUp).Row
 Let Lc = Ws1.Cells.Item(1, Ws1.Columns.Count).End(xlToLeft).Column
Dim arrIn() As Variant: Let arrIn() = Ws1.Range(Ws1.Range("A1"), Ws1.Cells.Item(Lr, Lc)).Value ' Data range in sample2.xlsx
Rem 2 make text file long string
Dim Rw As Long, Clm As Long '
    For Rw = 1 To Lr ' each row in Ws1
        For Clm = 1 To Lc ' each column for each row in Ws1
        Dim strTotalFile As String
         Let strTotalFile = strTotalFile & arrIn(Rw, Clm) & "," ' add a value and a seperator for this line
        Next Clm
     Let strTotalFile = Left(strTotalFile, Len(strTotalFile) - 1) ' this will take off the last  ,
     Let strTotalFile = strTotalFile & vbLf  ' this adds the line seperator wanted by Avinash  -  https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page30#post13348  -  You will see that vbLf is the separator for lines(records)
    Next Rw
 Let strTotalFile = Left(strTotalFile, Len(strTotalFile) - 1)     ' this takes off the last  vbLf
 Debug.Print strTotalFile
Rem 3 make text file from the  total string
Dim FileNum As Long
Let FileNum = FreeFile(1)                                  ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
 Open ThisWorkbook.Path & "\csv Text file Chaos\Alert..txt" For Output As #FileNum  ' CHANGE TO SUIT  ' Will be made if not there
 Print #FileNum, strTotalFile '                      strTotalFile
 Close #FileNum

End Sub






I don’t have any more time for you today. I will look again tomorrow at your latest questions



Alan





Share ‘sample2xlsx’ : https://app.box.com/s/np7kbvjydnyiu95pzyrgn76qi1uqg0ma
vba.xlsm : https://app.box.com/s/juekenyll42z84j6ms7qonzsngnugoyo