Exporting Emojis with VBA (How to make unicode)

Copper Contributor

Hi,

I'm trying to export an excel to multiple .txt files.

It works, but all Emojis transforms into "??". How do I make it a unicode .txt?

What am I doing wrong? Is it even possible? I got some of the code from here: http://www.exceltrainingvideos.com/tag/create-text-files-from-excel-data-automatically/

 

This is the code I'm using i VBA:

Sub ExportToNotepad()
Dim wsData As Variant
Dim myFileName As String
Dim FN As Integer
Dim p As Integer, q As Integer
Dim path As String
Dim lastrow As Long, lastcolumn As Long

lastrow = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
lastcolumn = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
path = "C:\Users\Bruger\Desktop\Chatbot\VBA Test\"

For p = 1 To lastrow
wsData = ActiveSheet.Cells(p, 1).Value
If wsData = "" Then Exit Sub
myFileName = wsData
myFileName = myFileName & ".txt"
myFileName = path & myFileName
'MsgBox myFileName
For q = 2 To lastcolumn
myString = myString & Cells(p, q)

FN = FreeFile
Open myFileName For Output As #FN
Print #FN, myString
Close #FN
Next q
myString = ""
Next p

End Sub

 

I'm new to VBA, so all help is appreciated :)

0 Replies