เจอปัญหา Macro อ่านไทยได้ที่ text editor แต่อ่านไม่ได้หลัง import เขียนลง excel
Posted: Fri Jan 14, 2022 12:17 am
สอบถามการเขียน Macro encoding
ถ้าอ่าน ด้วย Text editor อ่านไทยได้ เช่น "อัคริศา โตรักษา"
แต่พออ่านแล้วเขียนลง excel เป็น ภาษาอ่านไม่ออก ตามด้านล่าง
"เน€เธโฌเน€เธเธเน€เธเธ•เน€เธเธเน€เธเธเน€เธ"
มีคำสั่งอะไรที่ encoding ไหมครับ ให้แปลงให้อ่านภาษาไทยใน excel file
นี่คือ code ที่เขียนครับ
Sub ReatThaiTextfile()
Dim strFile As String
Dim strLine As String
FilePath = Range("c3").Value
strFile = FilePath
Open strFile For Input As #1
i = 1
Do Until EOF(1)
Line Input #1, strLine
detailRec = strLine
Worksheets("Test123").Cells(i, 4).Value = detailRec
i = i + 1
Loop
Application.ScreenUpdating = True
Close #1
End Sub
ถ้าอ่าน ด้วย Text editor อ่านไทยได้ เช่น "อัคริศา โตรักษา"
แต่พออ่านแล้วเขียนลง excel เป็น ภาษาอ่านไม่ออก ตามด้านล่าง
"เน€เธโฌเน€เธเธเน€เธเธ•เน€เธเธเน€เธเธเน€เธ"
มีคำสั่งอะไรที่ encoding ไหมครับ ให้แปลงให้อ่านภาษาไทยใน excel file
นี่คือ code ที่เขียนครับ
Sub ReatThaiTextfile()
Dim strFile As String
Dim strLine As String
FilePath = Range("c3").Value
strFile = FilePath
Open strFile For Input As #1
i = 1
Do Until EOF(1)
Line Input #1, strLine
detailRec = strLine
Worksheets("Test123").Cells(i, 4).Value = detailRec
i = i + 1
Loop
Application.ScreenUpdating = True
Close #1
End Sub