Merhaba aşağıdaki kod ile txt dosyası oluşturuyorum. Oluşan dosyanın txt “UTF-8” formatı olması gerekiyor ama kayıt sonrası baktığımda dosya formatı “Ürün Reçetesi ile UTF- 8“ formatında kayıt yapıyor. Konu hakkında bilgisi olan varsa yardımcı olabilir misiniz?
Sub Text()
Dim ws As Worksheet
Dim rng As Range
Dim i As Long
Dim txtLines As String
Dim filePath As String
Dim stream As Object
Set ws = ThisWorkbook.Sheets(1)
' B2:B501 aralığındaki hücreleri kontrol et
For i = 2 To 501
If Trim(ws.Cells(i, "B").Value) <> "" Then
txtLines = txtLines & ws.Cells(i, "V").Value & vbCrLf
End If
Next i
' Kaydedilecek dosya yolu
filePath = Application.ThisWorkbook.Path & "\Veriler.txt"
' UTF-8 ile dosyaya yazma
Set stream = CreateObject("ADODB.Stream")
With stream
.Charset = "utf-8"
.Open
.WriteText txtLines
.SaveToFile filePath, 2
.Close
End With
Set stream = Nothing
MsgBox "Dosya başarıyla oluşturuldu: " & filePath
End Sub
Sub Text()
Dim ws As Worksheet
Dim rng As Range
Dim i As Long
Dim txtLines As String
Dim filePath As String
Dim stream As Object
Set ws = ThisWorkbook.Sheets(1)
' B2:B501 aralığındaki hücreleri kontrol et
For i = 2 To 501
If Trim(ws.Cells(i, "B").Value) <> "" Then
txtLines = txtLines & ws.Cells(i, "V").Value & vbCrLf
End If
Next i
' Kaydedilecek dosya yolu
filePath = Application.ThisWorkbook.Path & "\Veriler.txt"
' UTF-8 ile dosyaya yazma
Set stream = CreateObject("ADODB.Stream")
With stream
.Charset = "utf-8"
.Open
.WriteText txtLines
.SaveToFile filePath, 2
.Close
End With
Set stream = Nothing
MsgBox "Dosya başarıyla oluşturuldu: " & filePath
End Sub