Share via

Diatrics in VBA editor (Microsoft 365 Excel)

Ivan Hrasko 0 Reputation points
2025-10-14T06:39:13.5633333+00:00

The VBA editor suddenly stopped displaying the diactrik for me, instead of letters with the diactrik it shows "?". In the VBA editor settings, I have the font "Courier New (Central-European" selected, it should probably be Central European languages, but I don't see it there. I noticed the change today when I opened the notebook. I corrected the diactric in some words, I saved the notebook and opened it again, the corrected words were no longer distorted and displayed correctly, so I would like to know what happened and how I can prevent it in the future and whether I can correct the original modules so that I do not have to correct everything manually? (Interestingly, in the "Class Module" the diactrik has been preserved)

Editor VBA mi z ničoho nič prestal zobrazovať diaktriku, miesto písmen z diaktrikou zobrazuje "?". V nastaveniach editora VBA mám vybratý font "Courier New (Stredoeuró" asi má byť Stredoeurópske jazyky čo ale tam nevidím. Zmenu som si všimol dnes pri otvorení zošita. Opravil som v niektorých slovách diaktriku uložil som zošit a znova ho otvoril opravené slová už neboli skomolené a zobrazovali sa správne, čiže by som chcel vedieť čo sa udialo a ako tomu v budúcnosti predídem a či dokážem opraviť pôvodné moduly, aby som nemusel všetko opravovať ručne? (Zaujímavé v moduloch triedy "Class Module" zostala diaktrika zachovaná)

Thank you for your reply Ďakujem za odpoveď

Microsoft 365 and Office | Excel | For home | Windows
0 comments No comments

1 answer

Sort by: Most helpful
  1. Ian-T 7,640 Reputation points Microsoft External Staff Moderator
    2025-10-14T10:46:28.07+00:00

    Hello Ivan Hrasko,

    Thank you for posting in Microsoft Q&A.

    I understand that you are experiencing diacritics not displaying correctly in the VBA editor for Microsoft 365 Excel.

    The VBA editor in Office relies on legacy ANSI code pages, not full Unicode support, which means:

    • If your system locale or font settings don't match the language of the diacritics, they will appear as ?.
    • If you select a font like Courier New, the editor may not properly render characters unless the system locale supports them.

    Here are some steps that you can kindly follow to help resolve this:

    1. Change your system locale:
      • Visit Control Panel > Region > Administrative tab > Change system locale.
      • Set it to the language that supports your diacritics.
      • Restart your PC after applying changes.
    2. Font Settings in VBA Editor:
      • In the VBA editor, go to Tools > Options > Editor Format.
      • Choose a font that supports your language.
    3. Avoid Unicode in VBA
      • VBA Editor doesn't support Unicode for code text. If you need Unicode characters in strings, use ChrW() or AscW() functions in your code:
             MsgBox ChrW(&H010D) ' Example for č
        
      For file paths or name with diacritics, use FileSystemObject instead of Dir() becuase Dir() does not work with Unicode.
    4. Replace Accented characters programmatically:
      • If you need to strip diacritics, you can use VBA function:
    Function StripAccent(ByVal s As String) As String
        Dim AccChars As String, RegChars As String, i As Integer
        AccChars = "ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðñòóôõöùúûüýÿ"
        RegChars = "SZszYAAAAAACEEEEIIIIDNOOOOOUUUUYaaaaaaceeeeiiiidnooooouuuuyy"
        For i = 1 To Len(AccChars)
            s = Replace(s, Mid(AccChars, i, 1), Mid(RegChars, i, 1))
        Next
        StripAccent = s
    End Function
    

    I hope it helps, please feel free to let me know if you need any further assistance.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".  

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. 


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.