How to Fix Reserved Error 5012 in VBA SharePoint Queries
Question details
The user needs to resolve reserved error -5012, which occurs when executing a previously working VBA query against a SharePoint list.

- 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.
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.
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.
Open your spreadsheet or database application and navigate to the 'Data' or 'External Data' tab on the main ribbon.
Click on 'Queries & Connections' or 'Linked Table Manager' to view all active data sources in your current file.
Locate the SharePoint list (e.g., 'OF_Orders') that is causing the error, right-click it, and select 'Refresh' or 'Relink'.
If a prompt appears, enter your organizational Microsoft 365 or SharePoint credentials to authorize the connection.

Verify List Structure and Permissions
Check if the underlying SharePoint list structure has been altered or if user permissions have been revoked by IT administrators.
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. Download the Installer: Visit the official WPS Office website and download the free installation package for your operating system.
- 2. Install WPS Office: Run the downloaded file and follow the on-screen instructions to complete the fast installation process.
- 3. Open Your Macro Files: Launch WPS Spreadsheet and open your existing .xlsm files to access and run your VBA scripts immediately.

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.




