How to save .txt as Unicode or UTF-8 in VBA
01:13 19 Jun 2015

I want that all my files be saved in unicode or utf-8 format and not ANSI.

Here is the code:

Sub cvelle()
Dim iRow As Long
Dim iFile As Integer
Dim sPath As String
Dim sFile As String


For iRow = 1 To Cells(Rows.Count, "B").End(xlUp).Row
    iFile = FreeFile
    With Rows(iRow)
        sPath = "E:\" & .Range("B1").Value & "\"
        If Len(Dir(sPath, vbDirectory)) = 0 Then MkDir sPath
        sFile = .Range("D1").Value & ".txt"
        
        Open sPath & sFile For Output As #iFile
        Print #iFile, .Range("E1").Value
        Close #iFile
    End With
Next iRow
End Sub

Now, I thought that just inserting the code below would be enough.

sFile = .Range("D1").Value & ".txt",FileFormat:= _xlUnicodeText

But it gives me an error.

excel vba unicode utf-8