สอบถาม VBA Export to Text File แล้วเป็น UTF-8 ครับ
Posted: Fri Mar 16, 2018 2:15 pm
สอบถามเรื่อง VBA Export to Text File ให้เป็น UTF-8 ซึ่งปัจจุบันยัง Save UTF-8 ไม่ได้ครับ ซึ่งเวลาเอาไปเปิดเป็นภาษาต่างดาวครับ
Sub saveText2()
Dim filename As String, lineText As String
Dim myrng As Range, i, j
StrSave = "C:\Users\11209244\Desktop\Line Bot\"
StrFile = Sheets("DATA").Range("E1")
filename = StrSave & StrFile & ".txt"
Open filename For Output As #1
Set myrng = Range("data")
For i = 1 To myrng.Rows.Count
For j = 1 To myrng.Columns.Count
lineText = IIf(j = 1, "", lineText & ",") & myrng.Cells(i, j)
Next j
Print #1, lineText
Next i
Close #1
End Sub
Sub saveText2()
Dim filename As String, lineText As String
Dim myrng As Range, i, j
StrSave = "C:\Users\11209244\Desktop\Line Bot\"
StrFile = Sheets("DATA").Range("E1")
filename = StrSave & StrFile & ".txt"
Open filename For Output As #1
Set myrng = Range("data")
For i = 1 To myrng.Rows.Count
For j = 1 To myrng.Columns.Count
lineText = IIf(j = 1, "", lineText & ",") & myrng.Cells(i, j)
Next j
Print #1, lineText
Next i
Close #1
End Sub