logo
search
OneDrive File Issues

Fix OneDrive Sync Pending for Excel Files Updated by VBA

Adam DavisAdam Davis Oct 22, 2026 868 views

Question details

Users experience a stuck or pending OneDrive synchronization state after an Excel file in Microsoft Teams is updated and saved via VBA.

How to Fix Pending OneDrive Synchronization for Excel Files Updated by VBA
Product
Microsoft Excel, OneDrive, Microsoft Teams
Device & OS
not provided
Scenario
Automating updates and saving an Excel workbook synced through Microsoft Teams and OneDrive using VBA macros.
Observed behavior
The Excel file remains in a 'sync pending' state within OneDrive indefinitely and fails to fully upload or synchronize with Microsoft Teams.
Before you start

Verify that your internet connection is stable and ensure your OneDrive desktop client is fully updated before troubleshooting VBA file-locking mechanisms.

Solution 1Recommended

Ensure VBA Properly Closes and Releases the Excel Workbook

File locking by the local Excel application prevents OneDrive from syncing the file. Explicitly closing and releasing the file object in your VBA code resolves the lock.

When VBA saves a workbook but does not fully release it from memory, the Windows operating system and OneDrive client perceive the file as 'in use'. This immediately pauses the synchronization process, resulting in a permanent pending state.

1
Open the VBA Editor

Press ALT + F11 in Microsoft Excel to open the Visual Basic for Applications editor.

2
Locate the save operation

Find the specific macro or module responsible for saving the targeted Excel workbook.

3
Add the Close command

Ensure you include the line 'Workbook.Close SaveChanges:=True' immediately after your data update operations are finished.

4
Release the workbook object

Set the workbook object variable to Nothing (for example, 'Set wb = Nothing') at the end of the script to completely release the file lock, allowing the OneDrive client to take over and sync the file.

Ensure VBA Properly Closes and Releases the Excel Workbook
Tip: Implement standard VBA error handling routines (e.g., 'On Error GoTo') to ensure the file is always safely closed and released even if the macro encounters an unexpected runtime error.
Free Microsoft Office alternative

Experience Smooth Cloud Sync with WPS Office

Dealing with frustrating OneDrive sync issues and VBA file locks in Microsoft Office? Try WPS Office. It provides robust spreadsheet tools with a lightweight architecture, ensuring smooth cloud synchronization without the typical file-locking bugs—all for free.

Fully compatible with Microsoft Excel formats (.xls, .xlsx, .xlsm) and advanced macro functionality.Lightweight installation process and significantly faster software loading times.Seamless and reliable built-in WPS Cloud synchronization that prevents 'sync pending' errors.Familiar ribbon user interface ensuring zero learning curve for switching users.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my Excel file show 'Sync Pending' in OneDrive?

A 'Sync Pending' status generally means OneDrive is trying to upload the file, but it is currently locked by another application process. In the case of VBA, if the script doesn't completely close the file or release its memory objects, OneDrive cannot access the file to execute the synchronization.

Does WPS Office support macros and VBA scripts?

Yes, WPS Office provides excellent native support for macros and VBA, allowing you to run your existing Excel scripts and automate workflows smoothly without needing to rewrite your code.

How do I force OneDrive to sync a stuck Excel file?

First, close the Excel application completely using the Task Manager to break any lingering background locks. If the file is still stuck, right-click the OneDrive icon in your system tray, pause the synchronization, and then resume it to reset the upload queue.

Where can I report complex OneDrive synchronization bugs?

If your sync issues persist beyond file-locking resolutions, it is recommended to post your detailed scenario in the OneDrive section of the official Microsoft Community forum where dedicated support engineers and MVPs can investigate client-specific problems.