Search code examples
excelunicodecharacter-encodingnon-ascii-charactersvba

Excel macro source code character encoding issue


My Japanese colleague created an Excel 2010 macro. When I try to edit the macro in excel, the comments have weird characters. It seems like there is a character encoding issue.

Here is some sample code:

Option Explicit

'ƒtƒ@ƒCƒ‹Ši”[ƒpƒXŽw’è iRow,Col j
'DefineXMLƒtƒ@ƒCƒ‹
Public Const P_stTempRow = 5
Public Const P_stTempCol = 3

I checked to see if there was a way to change the encoding used to interpret the source code but couldn't see any settings.


Solution

  • It is a character encoding issue. The original file was Japanese-localized using the encoding Shift-JIS, but the file is now being interpreted as the US and Western European default encoding of Windows-1252. I do not know a way to make Excel use another encoding for macros other than the localized default, other than to change your "Current system locale" in Windows settings to Japanese.

    enter image description here