How to delete a read only file

L

Lee Crew

I have a read only file on my C:\
I want to be able to delete this file with a macro. I've played round with
the kill function but cant seem to get it to work. Does anyone know how I can
do this?

Many Thanks
Lee
 
B

Bill Ridgeway

Go into Windows and right click on the file which brings up a menu.
Click on <Properties> and, on the <General> tab at the bottom take the tick
off <Read Only>

Regards.

Bill Ridgeway
Computer Solutions
 
L

Lee Crew

Thanks Bill, I know I can do this this way but I am trying to automate a
process by using a macro to delete the file.

thanks
Lee
 
D

Dave Peterson

You can change the attributes with SetAttr:

Option Explicit
Sub testme()
Dim myFileName As String
myFileName = "C:\test1.txt"
SetAttr myFileName, vbNormal
Kill myFileName
End Sub
 
L

Lee Crew

That worked perfectly many thanks for your help

Dave Peterson said:
You can change the attributes with SetAttr:

Option Explicit
Sub testme()
Dim myFileName As String
myFileName = "C:\test1.txt"
SetAttr myFileName, vbNormal
Kill myFileName
End Sub
 
Top