Delete read only Files on Computer, shared Network

If you are ever stuck in Excel VBA with the error 70 – Permission Denied, you might be experiencing the same problem I had. The file you are trying to delete or overwrite may be on a network location (mapped drive) or even on local PC folder. All you have to do is to first set the attribute of the file to normal and then kill it. This is how to delete read only files on computer or on a shared network:

MyFilePath = thisworkbook.path & “\FiletobeDeleted.txt”

SetAttr MyFilePath , vbNormal

Kill MyFilePath

It worked good for me and I found this method after  struggling for 2 hours. I had to rewrite on a text file on a mapped server location on intranet. This worked 🙂

Leave a Reply