Fix Excel VBA Refresh Query Error for SharePoint Users
Question details
Users need to resolve a run-time error that occurs when executing a VBA macro to refresh a query connection in an Excel workbook hosted on SharePoint.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A shared workbook on SharePoint contains a VBA macro designed to refresh query connections, which is executed by multiple users across different Excel versions.
- Observed behavior
- The VBA macro successfully refreshes the query for Microsoft 365 users but produces a run-time error for Office 2016 users, even though the manual 'Refresh All' button works for everyone.
Ensure that all affected users have sufficient SharePoint permissions to access the connected data sources and try running the macro on a downloaded local copy of the workbook to isolate network issues.
Standardize Excel Versions and Bitness
Mismatched Excel versions handle query object models differently, which is the primary cause of VBA run-time errors when refreshing modern connections.
Microsoft 365 and Office Professional Plus 2016 expose different Power Query features to VBA. A macro recorded or written in Microsoft 365 may reference query properties that do not exist in the 2016 object model.
Have all users open Excel, click on 'File' in the top ribbon, and select 'Account' to view their exact Office edition and version number.
In the same 'Account' menu, click 'About Excel' to check whether the installation is 32-bit or 64-bit, as mixed bitness can break ODBC and OLEDB connection drivers.
Update all affected users to Microsoft 365 to ensure full compatibility with the latest Power Query features and VBA object models.

Revise the VBA Macro for Backward Compatibility
Modify the VBA code to use older, universally supported connection objects instead of newer methods exclusive to Microsoft 365.
Use WPS Office for Reliable Data Processing
If version compatibility issues and VBA run-time errors in Microsoft Excel continue to disrupt your team's workflow, consider switching to WPS Office. It provides robust spreadsheet management, excellent compatibility with complex files, and a stable environment for your daily data tasks.
- 1. Download and Install: Visit the official WPS website to download and install the free WPS Office suite.
- 2. Open your Spreadsheet: Launch WPS Spreadsheet and open your existing .xlsm or .xlsx file directly from your local drive or cloud storage.
- 3. Manage Data and Macros: Navigate to the Data tab to manage your connections, or use the Tools tab to access the built-in Macro editor seamlessly.

Frequently Asked Questions
Why does the VBA query refresh work for one user but produce a run-time error for others?
This usually happens due to differences in Excel versions, such as one user having Microsoft 365 while others have Office 2016. Newer versions support updated Power Query object models that older versions do not recognize, causing the VBA script to fail.
Can I manually refresh the query if the VBA macro fails?
Yes. Even if the VBA macro returns a run-time error, users can typically bypass the script by navigating to the 'Data' tab in the Excel ribbon and clicking 'Refresh All' to update the queries manually.
Does storing the Excel file on SharePoint cause VBA run-time errors?
Hosting the file on SharePoint does not change the VBA syntax, but strict SharePoint permission levels, missing trusted locations, or network sync issues can occasionally prevent macros from fetching external data successfully.




