Permission & Access Issues

Fix Excel Macro Returning Different OneDrive or SharePoint File Lists

Jason MillerJason Miller Nov 2, 2026 870 views

Question details

Users are experiencing an issue where an Excel macro retrieves fewer or different files from a shared OneDrive or SharePoint directory depending on the user running it.

How to Fix Excel Macros Returning Different OneDrive and SharePoint File Lists
Product
Excel
Device & OS
not provided
Scenario
Running a VBA macro to retrieve a complete list of files from a shared SharePoint or OneDrive folder.
Observed behavior
The macro returns an incomplete list of files for specific users, even though they can view and edit all files properly when accessing the folder via the SharePoint web browser interface.
Before you start

Ensure that the affected users are actively signed into their Microsoft accounts on their local OneDrive client. Verify that their local OneDrive sync is up to date, not paused, and actively syncing the specific SharePoint document library.

Solution 1Recommended

Verify Local OneDrive Sync Paths and Status

Ensure that the macro is pointing to the correct local synced path and that OneDrive has fully downloaded the files for the affected user.

VBA macros typically rely on local file paths rather than cloud URLs. If a user's local OneDrive is out of sync, or if files are marked as 'online-only' and the macro cannot trigger a download, the files will not appear in the macro's return list.

1
Open the synced folder

Open File Explorer and navigate to the user's local OneDrive or SharePoint synced folder where the target files reside.

2
Force local download

Right-click the specific folder or files and select 'Always keep on this device' to force a complete download of all items to the local drive.

3
Check sync status

Click the OneDrive cloud icon in the Windows system tray to check for any sync errors, pending uploads, or paused syncing statuses.

4
Verify local path variables

Open the macro in the VBA editor (ALT + F11) and ensure the folder path relies on environmental variables (like Environ("USERPROFILE")) rather than hardcoded usernames.

Verify Local OneDrive Sync Paths and Status
Dynamic Paths: Using dynamic paths ensures that the macro seamlessly adapts to different Windows usernames without breaking the code.
Free Microsoft Office alternative

Try WPS Office for Seamless Macro Execution and File Management

If Microsoft Excel permissions and OneDrive sync issues continue to disrupt your team's workflow, consider switching to WPS Office. It provides robust support for VBA macros, excellent compatibility with Microsoft formats, and a lightweight environment that minimizes complex syncing conflicts.

  1. 1. Download and install: Visit the official WPS website to download and install WPS Office on your computer.
  2. 2. Open Spreadsheets: Launch WPS Spreadsheets and open your existing .xlsm file containing the macros.
  3. 3. Enable macros: Navigate to the 'Developer' tab on the ribbon and click 'Macros' to securely run or edit your VBA scripts.
Fully compatible with Microsoft Excel (.xlsx, .xlsm) files and formats.Advanced WPS Spreadsheet application with reliable built-in VBA macro support.Free and lightweight alternative that will not bog down your system resources.Familiar user interface for a zero-learning-curve transition for all users.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my Excel macro work perfectly for me but fail to list files for another user?

This usually happens due to hardcoded local file paths in the VBA code that differ by Windows username, mismatched SharePoint folder permissions, or incomplete OneDrive synchronization on the other user's computer.

Can reinstalling Microsoft Office fix macro file list issues?

Generally, no. Reinstalling Office does not resolve underlying SharePoint permission scopes, local OneDrive sync statuses, or logical path errors within the macro's VBA code.

How do I ensure my VBA macro uses the correct SharePoint path for all users?

Instead of hardcoding a direct path like C:\Users\JohnDoe\..., you should use VBA environmental variables such as Environ("USERPROFILE") & "\Company Name\SharePoint Folder" to dynamically adapt to each user's local synced path.

Why can a user see files in the SharePoint browser but not via the Excel macro?

The browser views the live files directly on the SharePoint server, while macros typically interact with the local synced copy via Windows File Explorer. If the local OneDrive app is paused, disconnected, or selectively syncing, the macro will not 'see' the latest cloud files.