0

I'm using data from excel to write a json file to be read into sketch. Special characters like ® and ™ aren't coming through and are being replaced with a ?. I'm assuming that the default encoding of the file generated is not unicode. Can unicode be specified when the file is written? Here is the script I'm using to write to the text file.

Dim myFile As String
myFile = ThisWorkbook.Path & "/display_data_test.json"
Open myFile For Output As #1
Print #1, JSON
Close #1

I tried:

Dim myFile As String
myFile = ThisWorkbook.Path & "/display_data_test.json"

Dim fsT As Object
Set fsT = CreateObject("ADODB.Stream")
fsT.Type = 2
fsT.CharSet = "utf-8"
fsT.Open
fsT.writetext JSON
fsT.SaveToFile myFile, 2

This just gave me an error.

  • 2
    "an error" is not a very useful description of what happens when you run your code. – Tim Williams Jul 10 '23 at 20:13
  • `ThisWorkbook.Path` may be an http path, or you may not have write access to the location. – Tim Williams Jul 10 '23 at 20:20
  • @TimWilliams …True, but neither is your answer. The file path works fine. I’m trying to figure out how to assign Unicode encoding to the file… like it says in my question. – notAdev Jul 12 '23 at 01:04
  • Your question contains no description of the *actual problem* you're having with that code (which is the accepted answer in a previous post, so should work fine, and I know it has for me in the past). Given that, it's not clear how you expect us to be "useful" to you. – Tim Williams Jul 12 '23 at 01:16
  • See: https://learn.microsoft.com/en-us/office/client-developer/access/desktop-database-reference/charset-property-ado the default value of the .charset property is "Unicode", so don't set .charset to "utf-8" – hennep Jul 12 '23 at 08:46
  • And use StrConv to convert a string to unicode – hennep Jul 12 '23 at 08:50
  • @TimWilliams I'd rather people were kind than useful. You sir, are neither. – notAdev Jul 12 '23 at 14:46

0 Answers0