Unicode characters in VBA Macros in Excel? - excel

I have list of students and i want to invert the "Name Surname" format to "Surname Name".
My problem isn't the coding, but it's the UTF-8 support for my language.
I tested the macro with looping through the names and displaying them in a msgBox, but i get question marks for every name.
Anyone else had problems with UTF-8 in Excel Macros?

UTF-8 and Unicode mean different things, so it's hard to understand what you're asking for.
In principle, VBA uses 2-byte unicode (UCS-2) internally. This is not the same as UTF-8 which many external programs expect.
The StrConv() built-in function can convert back and forth.

Related

An issue when generating text with national symbols using VBA in Excel 2019

I am using some VBA add-in to generate text from numbers, that text contains national Lithuanian, German or any other national symbols. This used to work fine with the previous versions of Excel so far, but the system has now been upgraded from scratch and it does not seem to work well with Excel 2019.
In VBA, the code looks fine and you can see the national symbols like "š" (well after setting the locale to Lithuanian, before they were appearing as multiple strange symbols):
, however when in excel the functional is called, the output has just � instead of any national symbol. All of the national symbols are marked with the same � sign in Excel 2019. But you can write manually national symbols just fine in Excel, just what comes out of VBA is garbage missing those symbols.
It looks like this in a cell:
Trys �imtai �, 00 ct
Does anybody know how to fix this and make them appear normal with how they are visible within the code?
A few other observations are that when copying and pasting the code from the VBA Editor to Notepad++ the national symbols get lost as well and they appear as different strange symbols. Also when trying to use the find function in the VBA Editor window to find anything with the national symbols - no results are ever found as long as you don't remove the national symbols...
In my understanding, support for "international" ("non-Latin") characters is determined by your Windows Regional Settings, not by Excel or by the VBA IDE.
Since I'm in Canada I can't easily test on my end to verify this, but interestingly, your example character of š displays the opposite of how it shows for you: it renders properly on the worksheet but as gibberish in VBA.
Incidentally I determined the Unicode id number for š (Unicode 353) by pasting the symbol into cell A1 and then in another cell using formula =UNICODE(A1). The opposite function (to return a character from it's code) is UNICHAR. The VBA equivalents are AscW and ChrW.
I was aware that the VBA IDE can be made to display "international" characters by adjusting Windows Regional Settings (like discussed here), but I didn't realize any setup would make them not render on the spreadsheet since for me, most Unicode characters display properly on a worksheet.
I assume the characters don't work for you in other applications besides Excel. If that's not the case, and this problem is specific to Excel (or if you can't otherwise get it figured out by adjusting Windows Regional Settings), then I'd suggest contacting Microsoft Tech Support.
More information is here or here or in this search might also be helpful.
hi i had same problem in latvian
just uncheck utf - 8 beta in regional language settings for non unicode
enter image description here

VBA - How to filter for french words or another language with accents

I am running a macro that has to autofilter for specific words for a number of languages. However since VBA does not read unicode I have had to be creative in filtering for languages such as Japanese. I recorded myself filtering for はい and within the recorded macro it denoted this as "‚Í‚¢". I was able to use this same method to essentially have VBA read and output in Japanese.
I am working on the other languages now and have run into a wall as this same method does not seem to work with languages with accents. For example in French, d'enchères, simply is recorded as d'encheres so when I run the macro it does not find d'enchères.
2 part question:
1) What language/code is "‚Í‚¢"? Why is VBA able to read and display this as はい but I cannot directly input はい into my code?
2) Any suggestions on a way for me to autofilter for specific words that contain accents?
Any help is appreciated, as I am a novice!

Remove Unicode UTF-8 character from string in VBA

I'm using excel vba to take a dataset and build an XML file.
The data comes in with some unicode characters inside some of the comments fields.
This causes problems for the XML.
Would like to strip out any of these non-printable characters during the vba process.
Thanks
WorksheetFunction.Clean() should help: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.worksheetfunction.clean%28v=office.14%29.aspx

Opening VBA code exchanges characters

I have a problem with some code I have written in an English version of Excel 2011 for mac. When I open the workbook in Excel 2013 in Swedish certain Swedish letters in the code get converted to other characters, rendering the code useless. In other words, I have used special characters to define variables (I know, not good practice) and as conditionals (If x = 'Ombeställning' for example).
Is there an easy way to force the compiler to read my code as UTF-8? I'm on a tight deadline and I really don't feel like retracting all my variable declarations and subsequently changing my defined range names. If there is no other way, please tell me so I can get on changing the code.
Lastly, opening the workbook in Excel 2013 changed some of the row widths/heights, is this avoidable? I've spent a lot of time on formatting and it simply doesn't look professional when parts of the text are cut off etc.
EDIT: I forgot to mention I am opening 'Excel 2013 ' on a PC, which is probably the culprit regarding character encoding rather than the Excel version language.

How to insert Japanese character to ECC from Excel vba

I can see the Japanese text in the Excel cells. I've got the VBA code to update ECC. It does the INSERT in the ECC, but Japanese characters are simply represented as ????.
Any help would be appreciated.
Sorry, feels like it's been quite a time since the question was raised.
But still I'd like to propose a solution:
Using unicode encoding to represent different language:
Sheet1.Cells(2, 1) = ChrW(&H3091),
which is standing for character ゑ.
You need MS Excel Japanese Language Pack to display Japanese characters.
If you are importing text into Excel, you need to set the following.
.TextFilePlatform = 850
http://www.ozgrid.com/forum/showthread.php?t=141269

Resources