logo
search
VBA & Macro Problems

How to Use the Google Translate API from VBA in Access

Jason MillerJason Miller Oct 22, 2026 869 views

Question details

The user needs a VBA function in Microsoft Access to automatically translate text stored in tables by passing the source text and target language to a translation API.

How to Use the Google Translate API from VBA in Access
Product
Microsoft Access
Device & OS
not provided
Scenario
Automating text translation within an Access database using VBA scripts and the Google Translate API.
Observed behavior
The goal is to accept source text and a target language parameter, and return the translated text directly into the Access table or form without relying on a manual side pane.
Before you start

Before integrating the Google Translate API, ensure you have an active Google Cloud account, a valid API key with billing enabled, and basic knowledge of making HTTP requests in the VBA editor.

Solution 1Recommended

Integrate Google Translate API using VBA HTTP Requests

Use MSXML2.XMLHTTP to send a REST API request to Google Cloud Translation and parse the JSON response in Access VBA.

To translate text programmatically, you need to send a POST request to the Google Translate REST API endpoint. Because VBA does not natively parse JSON data, utilizing VBA-JSON libraries (such as those found in the VBA-tools GitHub repository) will greatly simplify extracting the returned translation.

1
Obtain an API Key

Log in to the Google Cloud Console, navigate to the API & Services dashboard, enable the 'Cloud Translation API', and generate a new API key.

2
Include necessary references

Open the Access VBA Editor (Alt + F11). Go to Tools > References and check 'Microsoft XML, v6.0' to enable HTTP requests, and 'Microsoft Scripting Runtime' for dictionary support.

3
Write the HTTP Request function

Create a VBA function that formats the endpoint URL (https://translation.googleapis.com/language/translate/v2), appends your API key, and sends the text and target language parameters using the MSXML2.XMLHTTP object.

4
Parse the JSON response

Import a JSON parser module (like JsonConverter from Tim Hall's VBA-tools repository). Use it to extract the translated string from the API's response payload and assign it to your Access table record.

Use Community Tools: Tim Hall's GitHub repository (VBA-tools) contains highly reliable tools like VBA-JSON and VBA-Web that can dramatically speed up API integrations in Microsoft Access.
Free Microsoft Office alternative

Looking for a Lightweight Alternative for Office Macros?

While Microsoft Access is a specialized database tool, many data processing and VBA macro tasks can be efficiently handled in powerful spreadsheets. WPS Office provides excellent compatibility with Microsoft Office formats and supports VBA macros, making it a powerful, free alternative for your daily data translation and management workflows.

  1. 1. Download the Installer: Visit the official WPS Office website and download the free installation package tailored for your operating system.
  2. 2. Install the Suite: Run the installer and follow the simple on-screen instructions to set up WPS Office on your computer.
  3. 3. Enable Macros: Open WPS Spreadsheet, navigate to the Developer tab, and start writing or importing your VBA macros to automate your tasks.
Highly compatible with Microsoft Office file formats including .xlsx, .docx, and .pptx.Robust support for VBA and Macros to automate complex data workflows.Lightweight installation with a familiar, easy-to-use interface for quick onboarding.Free to download and use for your essential office and data-entry tasks.
microsoft office alternative - wps office

Frequently Asked Questions

Can I use the Google Translate API for free in VBA?

Google offers a limited free tier for the Cloud Translation API, but you still need to set up a billing account in the Google Cloud Console to obtain the active API key required for your VBA HTTP requests.

Why am I getting a JSON parsing error in my Access VBA code?

VBA does not have native support for parsing JSON data. You must use a third-party library, such as VBA-JSON from the VBA-tools GitHub repository, and ensure that the 'Microsoft Scripting Runtime' reference is checked in the VBA editor tools.

Is there a built-in translate function in Access or Excel VBA?

No, while Word and Excel have built-in translation task panes, there is no native =Translate() function available out-of-the-box. You must use REST APIs or web scraping techniques via VBA to pull automated translations directly into your database tables or spreadsheet cells.