Forum Discussion

MartinGM's avatar
MartinGM
Copper Contributor
Sep 18, 2025

Save and close large files

I have a decent internet connection from my Windows 11 laptop - around 20 mbps upload, 70 mbps download and a ping time around 10 to 15 ms.

Most of the files I work with in the OneDrive area of my laptop are under 10 MB and their mirroring to the cloud is fine.

I also use files (mostly Excel or Word) bigger than that and they regularly do not mirror properly.

  • If I save one of these larger files then close it a little while later, the file is synched properly and all is well.
  • However if I just close one of these larger files (and am prompted to save it, to which I agree) I get one of a variety of error messages, ranging from saying that the server version has been edited to a message that I have to open the file and save it (or save-as) to synchronise things. The same happens if I use a save-and-close routine in VBA (Excel or Word).

This is reproducible - it seems clear that if the "close" instruction follows too soon behind the "save" instruction, OneDrive can't and doesn't cope.

This is annoying when I'm saving/closing the file "manually" then have to clean-up afterwards but I can do the "save, wait, close thing, and a real pain when I want to save and close from VBA when I don't have the option to wait between the save and the close instructions.

Surely this isn't how OneDrive is supposed to function, or is there a workaround or something else that I am missing ?

5 Replies

  • Mageee's avatar
    Mageee
    Brass Contributor

    It sounds like OneDrive is not finishing the sync process before the file is closed. This is especially noticeable with larger Office files. A few things you can try:

    First, make sure the OneDrive client is fully updated. Microsoft has pushed fixes in recent builds for sync timing issues.

    Second, instead of relying on save-then-close happening instantly, add a short delay. For manual work, that means saving, waiting a few seconds, and then closing. For VBA automation, you can use Application.Wait or a similar pause after Save before running Close.

    Third, check if Files On-Demand is enabled. Sometimes disabling it for the specific folder where you keep large Office documents helps, since the files are kept fully local and reduce sync lag.

    If the problem keeps happening, it may be worth opening a support case with Microsoft since this looks more like a limitation in how OneDrive handles back-to-back save and close requests rather than something wrong with your setup.

  • NikolinoDE's avatar
    NikolinoDE
    Gold Contributor

    Based on what you described (Windows 11, OneDrive for Business, large Excel/Word files, VBA macros).

    What’s happening is basically a race condition between:

    • Office telling OneDrive "file is saved, sync it"
    • You (or VBA) telling Office "close the file immediately"

    When the save and close come back-to-back, OneDrive/Office Upload Center sometimes doesn’t have time to update the cached copy before the file handle closes. That’s why you see “server version has been edited” or “please re-save” errors, especially on larger files.

    Manual habit (what you’ve already discovered)

    • Do Ctrl+S (Save), wait a couple of seconds until the OneDrive icon shows a small green check, then close.
    • Annoying, but works.

    VBA workaround (best option for automation)

    Here’s a drop-in VBA procedure you can add to any Excel file (or your Personal Macro Workbook), and then call it instead of ThisWorkbook.Close or ActiveWorkbook.Close.

    ' ================================
    ' Safe Save-and-Close for OneDrive
    ' ================================
    ' Call SafeClose ThisWorkbook
    ' or SafeClose Workbooks("MyFile.xlsx")
    ' instead of .Close
    
    Public Sub SafeClose(wb As Workbook, Optional DelaySeconds As Double = 2)
        On Error GoTo ErrHandler
        
        ' 1. Save explicitly
        wb.Save
        
        ' 2. Give OneDrive/Office Upload Cache time to catch up
        If DelaySeconds > 0 Then
            Application.Wait (Now + TimeSerial(0, 0, DelaySeconds))
        End If
        
        ' 3. Close without asking again (already saved above)
        wb.Close SaveChanges:=False
        Exit Sub
        
    ErrHandler:
        MsgBox "Error closing workbook '" & wb.Name & "': " & Err.Description, vbExclamation
    End Sub

    Anywhere you would normally write:

    ThisWorkbook.Close SaveChanges:=True

    This way, the explicit Save happens, OneDrive has ~2 seconds to register it, and then the workbook closes without prompting.
    You can adjust the delay if needed (2–5 seconds for large files).

     

    Disable "Use Office applications to sync Office files"

    • In OneDrive settings → Office tab → uncheck "Use Office applications to sync Office files I open".
    • This makes OneDrive do the syncing instead of relying on the Office Upload Cache.
    • Many users report it fixes weird save/close sync issues (but you lose some coauthoring features).

     

     

    My answers are voluntary and without guarantee!

     

    Hope this will help you.

     

    Was the answer useful? Mark as best response and like it!

    This will help all forum participants.

    • MartinGM's avatar
      MartinGM
      Copper Contributor

      That is very clear and very helpful, thank you. I knew it was a race !

      I will work the VBA into my code.

      Martin

      • MartinGM's avatar
        MartinGM
        Copper Contributor

        I have re-worked my VBA and all's well on that front - thanks again. Some of the files need 4 seconds - I'm OK with that.
        As for OneDrive settings → Office tab → uncheck "Use Office applications to sync Office files I open", I don't have an Office tab in OneDrive setting, or the option you mention. Maybe its a OneDrive for Business thing ? I am using an Office365 1TB OneDrive subscription

Resources