"your changes could not be saved because of a sharing violation"
Olivia Zamora
I have Excel 2013 64bit running a macro that goes through a series of files in my local drive, opens them, refreshes the power queries inside, save and close; this process runs daily, and has worked well since the beginning.
Yesterday one of the files could not be saved, with the message "your changes could not be saved because of a sharing violation", then Excel tries to force me to save with another name. I also cannot delete or cut the file, saying the file is "opened in system".
Since yesterday, this behavior has spread to two more files, rendering them useless. I cannot find a rational explanation nor a solution for this, and this process is critical for my company.
Saving in another directory is also not an option, because those files are mapped as source files for a lot of Tableau reports, and they must be read at their current location and name.
Any help or insight would be great!
32 Answers
You need to find out what is keeping the files locked so that they cannot be written to. Either Excel itself (perhaps there is a second instance of Excel opened at the same time? Could your application be running in another instance?? Could a previous instance have crashed, leaving the file locked???) or another program, such as an anti-virus application, has opened the file.
There are various ways to monitor a file to check what is accessing it, as has been answered on StackExchange. Microsoft provides a brief explanation, and Webspy and Lepide offer further explanations.
Another useful tool is LockHunter, which will tell you what process is locking a file and allow you to unlock it.
On Mac running Catalina (OS X 10.15.4), enabling Full Disk Access in System Preferences/Privacy for each of the Microsoft Office tool (Excel, Powerpoint, Word) seems to resolve the problem. That solution was highlighted on G-Suite support and Microsoft website, but those threads are oddly locked...