Using national language support in Office with VBA

Localization demo application screenshot
Localization demo application screenshot

If you need to handle multiple languages, get some specific regional settings, or do things like implement dynamic runtime language switching in your Microsoft Office solutions, you can leverage some additional help using the national language support Win32 API in VBA.

Do you know why you have to use the US English date format when you assign a date literal to a variable in VBA or in a SQL statement, surrounding it with “#” characters (like in: MyDate = #1/6/2020# for the 6 jan. 2020) ?
That’s because VBA (and the Office Object Model) is internally language locked on the locale which language ID is #1033.

What’s a locale and a language ID ? That’s how Windows manages multi language support.

There’s a lot of information about that on MSDN and on the web. Too much in fact to get started quickly.

This post will try to help you spare some time, make that journey quick and easy and jump into action now.

Here you’ll find :

Localization with VBA and the Win32 API demo

National language support with the Windows API

From MSDN:

The National Language Support (NLS) functions help applications support the different language- and locale-specific needs of users around the world.

The National Language Support (NLS) functions permit applications to:

  • Set the locale for the user
  • Identify the language in which the user works
  • Retrieve strings representing times, dates, and other information formatted correctly for the specified language and locale

Locales and Languages

Here’s the short version, while the full version of this topic is on MSDN.

Microsoft Office Application object language settings

Each VBA project in an Office application has access to a global Application object that has a:

Example (demo database)

Localization_win32.accdb, in this github repository, is an Access Database that illustrates how we can retrieve these language and regional settings from VBA.

It contains the MIntl.bas standard Visual Basic module, that wraps the necessary Win32 API functions and declarations. It also provides shortcut functions for some frequently used settings.

More on globalization

Globalization Documentation portal on MSDN.


The files of this project are in the github repository, including the demo database (MIT license).