Runtime error 70 with VBA while closing Excel

Viewed 31

I've been currently troubleshooting a random error that occurs. We have a series of Excel sheets that when you open them, will make a copy of them on the server. The user will input their data, save it, and then when they close Excel, there is VBA code that will make a copy of the file and then run a KILL command to the file that is being used.

For the most part, this functions correctly. However, for some users they will get the Run-time error 70: Permission denied. I have checked the permissions to the folder and file and have confirmed that the users do have permission to delete and modify files.

The same user having this trouble can log into another computer and it will work fine. Another user can log on to the computer giving trouble and it will work fine.

What I have found that helped was if I removed the user's profile on the computer, when they signed back and it recreated it, it would work. However I've had one after testing it confirming it worked, I reconfigured the One Drive app to sync his desktop, documents, etc.. and then it broke again. I had to redo his profile but without One Drive this time. For another user, it worked until I configured Outlook.

In all of these cases, copying the file to their desktop, the code will work properly every time. I have even checked the server while the run-time error is up and I am not able to see any file locks being held on the server. For additional testing, I have copied some of these files to another 2019 file server and it is experiencing the same issues. I have also set the network path the files are stored in as a trusted location.

All of the computers in question run Windows 10 version 21H2 and are all using Office 365. The server is running Server 2019 Datacenter version 1809.

At this point, I'm not sure what else I can check. I have for testing, put in a sleep command for 30 seconds prior to running the Kill command to see if it was trying to Kill the file too quickly. It appears to be that when Excel is closing the file, the server is not releasing the file lock even though it doesn't show that the file is open on the server.

At this point, I'm not sure what else I can try and I'm open to suggestions on what I can check.

I'm including a snip of the code it is failing at. Kill previous_full_path

0 Answers
Related