SaveAs causes a runtime error 1004 while the file is syncing to OneDrive

iamjamieq

New Member
Joined
May 22, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I have some code that saves a copy of a workbook to my OneDrive folder. If I save the file, and the file starts syncing to OneDrive, and I try to save the file again (for whatever reason) while it is still showing as syncing, I get runtime error 1004 for the SaveAs method. From what I can gather from searching, this is because the file goes into kind of a read only state while syncing. I tried adding "Kill (fileName)" to the code before saving, since it is possible to delete the file while it is syncing, but even this is hit or miss. The only kludge that works is running the Kill command and then a delay of 5 seconds to make sure the file was deleted, and then the SaveAs. Is this the only way to handle it, or is there a parameter of the SaveAs method that will work even while the file is syncing?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top