Link to home
Start Free TrialLog in
Avatar of Jen Payne
Jen Payne

asked on

VBA .txt File UTF8 Encoding

I'm trying to create a .txt file with UTF8 encoding, the script below works but does not product an UTF8 encoded file:


     
            Dim fs As Object

    Dim stream As Object

     
    Set fs = CreateObject("Scripting.FileSystemObject")

    On Error GoTo fileexists

        Set stream = fs.CreateTextFile(DEMFolder2.SelectedItems(1) & "\" & DEMFolderString & "\1. Load Files\" & DEMNumber & ".txt", False, True)


fileexists:

        If Err.Number = 58 Then

            MsgBox "File already Exists"


        Else

            stream.Write ("DEM Claim Number=" & DEMNo)
            stream.WriteLine
            stream.Write ("RECORDING match file name=" & CMFilename & ".csv")
            stream.WriteLine
            stream.Write ("MEMBER match file name=" & MIDFilename & ".csv")
            stream.WriteLine
            stream.Write ("PERFORMER match file name=" & PIDFilename & ".csv")
            stream.WriteLine
            stream.Write ("Performer Single/Multiple Role [S/M]=S")
            stream.WriteLine
            stream.Write ("Collecting Society=" & Soc)
            stream.WriteLine
            stream.Write ("New Society [Y/N]=" & NewSoc)
            stream.WriteLine
            stream.Write ("Country=" & Country)
            stream.WriteLine
            stream.Write ("Description=" & DEMDescription)
            stream.WriteLine
            stream.Write ("Distribution Start Year=" & AirStart)
            stream.WriteLine
            stream.Write ("Distribution End Year=" & AirEnd)
            stream.Close

        End If

    On Error GoTo 0
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jen Payne
Jen Payne

ASKER

Hi Rgonzo1971,

Thanks!

Do you know how I can do that with multiple (separate) Lines
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That's great, worked perfect!
Solution according to Author's comment