Reputation: 31
I'm facing a problem when trying to call AppleScript (MacScript) to read out aloud non-Latin characters from VBA on Mac Excel 2011 (e.g. text in specific Excel cells). The following code line is working fine to read French text using the synthetic voice "Audrey":
MacScript ("say """ & FrenchStrg & """ using ""Audrey""")
FrenchStrg e.g. "croissant"
However, when trying to use the same code for Greek using the synthetic voice "Nikos", as in
MacScript ("say """ & GreekStrg & """ using ""Nikos""")
GreekStrg e.g. "ούζο"
most of the string (in Greek characters) is interpreted as "_" and is therefore not read aloud (the command "say "ούζο" using "Nikos"" is working fine in the AppleScript editor). In some cases, a few letters may be interpreted as some special character and are read out accordingly, but I couldn't find a useful pattern.
When changing the standard language of Mac OsX from English to Greek, the characters are correctly recognized within the VBA editor and in a MsgBox. However, the output to MacScript is still not working. Does the VBA MacScript function only accept non-unicode text? Is there any solution?
Any help would be much appreciated!
Upvotes: 2
Views: 872
Reputation: 31
Thank you @Zero for suggesting to use the clipboard. This did indeed solve the problem. Here is the final working code:
Cells(1, 1).Copy
MacScript ("say (the clipboard) using ""Nikos""")
This circumvents the problem of strings getting converted into non-unicode text.
Upvotes: 1
Reputation:
I don't think this will work but to be sure you should try it anyway:
MacScript ("say """ & (GreekStrg as Unicode text) & """ using ""Nikos""")
Unicode Support
AppleScript is now entirely Unicode-based. Comments and text constants in scripts may contain any Unicode characters, and all text processing is done in Unicode, so all characters are preserved correctly regardless of the user’s language preferences. For example, this script works correctly in AppleScript 2.0, where it would not have in previous versions:
set the Japanese_phrase to "日本語"
set the Russian_phrase to "Русский"
set the new_phrase to the Japanese_phrase & " and " & the Russian_phrase
return new_phrase
Upvotes: 0