1

I want to create a text file with a filename that has some Cyrillic characters.

This MS Word VBA code does not work since I moved from Windows to Mac:

Dim fname As String
fname = db_path + "кириллица-test123.txt"
Close #1

Open fname For Output As #1
Print #1, "Hello!"
Print #1, "Привет!"
Close #1

I get

Run-time error '75': "Path/File access error".

It works if I say:

frame = db_path + "test.123.txt"

I learned File System Objects are only supported on Windows.

I am on macOS (default language = Russian). I do not know any way to create a text file other than the "Open" statement.

I tried applying StrConv function to the filename.

3
  • Try support.apple.com/en-by/guide/mac-help/mchl14cc6599/mac Commented May 14, 2023 at 12:07
  • Thanks! This I have tried already - the default language is Russian. But it did not help - same error. Commented May 14, 2023 at 15:12
  • Do you have the same problem with AppleScript? Commented May 14, 2023 at 18:53

1 Answer 1

1

Can't provide a solution to this right now, but...

The main problem here seems to be that on Mac, the old built-in VBA File commands only recognise 8 bit character codes.

What I can't tell without a lot of reconfiguration of my Mac is exactly how that affects someone who has a Mac set up for a Cyrillic script language.

Here (on an English language set-up) it affects what I see in the VB Editor (i.e. all the Cyrillic characters appear as "?"). That's expected.

But let's say I change your file name to a single Cyrillic-Њ character using this:

fname = db_path +  Chr(&H400)  & "-test123.txt"

I get an "invalid procedure call or argument" error.

But if I use the 2-byte UTF8 equivalent of &H400, like this...

fname = db_path + Chr(208) & Chr(138) & "-test124.txt"

...a file is created with a name starting with the &H400 character as you might hope.

further, using Chr(208) & Chr(138) to write the same character to the file seems to work.

No solid ground for a solution there, but perhaps something to explore as I am away for a few days now.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.