VBA – write to UTF file (with BOM)

Dim objStream
Set objStream = CreateObject("ADODB.Stream")
objStream.Open
objStream.Charset = "UTF-8"
objStream.Position = 0
objStream.WriteText sTxt
objStream.SaveToFile sFileName, 2
objStream.Close

Leave a Reply