VBA & Macro Problems

How to Fix Reserved Error 5012 in VBA SharePoint Queries

Natalie TaylorNatalie Taylor Oct 23, 2026 869 views

Question details

The user needs to resolve reserved error -5012, which occurs when executing a previously working VBA query against a SharePoint list.

How to Troubleshoot Reserved Error 5012 in a SharePoint Query
Product
VBA / Spreadsheet
Device & OS
not provided
Scenario
Executing a VBA SQL query (such as SELECT TOP 1 ID FROM OF_Orders) on a connected SharePoint list to retrieve the latest records.
Observed behavior
The query fails to execute and returns a "reserved error -5012" message instead of the requested data, likely indicating a dropped connection or permission failure.
Before you start

Verify that your network connection is stable and that you can access the target SharePoint list directly through a standard web browser before modifying your VBA code.

Solution 1Recommended

Refresh or Relink the SharePoint Data Connection

Use this solution to restore broken connectivity or refresh expired authentication tokens between your spreadsheet and the SharePoint list.

Reserved error 5012 typically indicates that the internal database engine has lost contact with the external SharePoint data source. Relinking the tables or refreshing the data connection forces the system to re-authenticate and re-establish the connection tunnel.

1
Access Data Connections

Open your spreadsheet or database application and navigate to the 'Data' or 'External Data' tab on the main ribbon.

2
Open Connection Manager

Click on 'Queries & Connections' or 'Linked Table Manager' to view all active data sources in your current file.

3
Refresh the Specific List

Locate the SharePoint list (e.g., 'OF_Orders') that is causing the error, right-click it, and select 'Refresh' or 'Relink'.

4
Re-authenticate

If a prompt appears, enter your organizational Microsoft 365 or SharePoint credentials to authorize the connection.

Refresh or Relink the SharePoint Data Connection
Connection Restored: Once the connection is successfully refreshed, your VBA script should be able to execute the query without triggering error 5012.
Free Microsoft Office alternative

Try WPS Office for a Seamless and Free Macro Experience

If persistent SharePoint connection errors and Microsoft Office limitations are disrupting your workflow, consider switching to WPS Office. It provides a lightweight, highly compatible alternative with robust support for VBA macros and data manipulation.

  1. 1. Download the Installer: Visit the official WPS Office website and download the free installation package for your operating system.
  2. 2. Install WPS Office: Run the downloaded file and follow the on-screen instructions to complete the fast installation process.
  3. 3. Open Your Macro Files: Launch WPS Spreadsheet and open your existing .xlsm files to access and run your VBA scripts immediately.
Completely free and lightweight alternative to Microsoft Office.Seamless format compatibility with Microsoft Excel (.xlsx and .xlsm) files.Built-in professional VBA editor for running and debugging macros.Familiar tabbed user interface for an effortless migration.
microsoft office alternative - wps office

Frequently Asked Questions

What does reserved error -5012 mean in VBA?

Reserved error -5012 is a generic error thrown by the Jet/ACE database engine when it fails to communicate with an external data source, such as a SharePoint list. It typically points to a broken network connection or an expired authentication token.

Why did my SharePoint VBA query suddenly stop working after years?

Sudden failures are usually caused by external infrastructure changes. This includes updates to your organization's IT security policies, expired SharePoint credentials, enforced multi-factor authentication (MFA), or structural changes made to the SharePoint list.

How can I get more detailed error information in VBA?

You can wrap your connection or execution code in an error handling block using 'On Error GoTo ErrorHandler'. Within the handler, use 'MsgBox Err.Number & " - " & Err.Description' to print out exact diagnostic messages that might provide more context than the generic 5012 code.