0

I have the following encrypted text in cell A1:

ԓԗՃխՓ՛Րե՘Ր՞՚ըՖՑ՟խՑՙՔը՟՗՝ՇխՑ 

I am trying to write this in a text file but the text shows as question marks characters ????????????????? in the text file.

Here is my code:

textFilePath = ThisWorkbook.Path & "\customfile.txt"
FF = VBA.FreeFile
Open textFilePath For Output As #FF
Print #FF, CStr(Sheet1.Cells(1,1).Value)
Close #FF

FYI: If I manually copy and paste the value of cell A1 in notepad, the text shows fine.

Community
  • 1
  • 1
JoaMika
  • 1,727
  • 6
  • 32
  • 61

1 Answers1

0

You cannot write like a normal text... You need to write like UTF-8:

Dim fsT As Object
Set fsT = CreateObject("ADODB.Stream")
fsT.Type = 2 'Specify stream type - we want To save text/string data.
fsT.Charset = "utf-8" 'Specify charset For the source text data.
fsT.Open 'Open the stream And write binary data To the object
fsT.WriteText Sheet1.Cells(1, 1).Value
fsT.SaveToFile "e:\0\customfile.txt", 2 'Save binary data To disk

taken from:

Save text file UTF-8 encoded with VBA

Community
  • 1
  • 1
user3514930
  • 1,721
  • 1
  • 9
  • 7