ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How to delete a read only file (https://www.excelbanter.com/excel-discussion-misc-queries/130284-how-delete-read-only-file.html)

Lee Crew

How to delete a read only file
 
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

Bill Ridgeway

How to delete a read only file
 
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

"Lee Crew" wrote in message
...
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




Lee Crew

How to delete a read only file
 
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

"Bill Ridgeway" wrote:

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

"Lee Crew" wrote in message
...
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





Dave Peterson

How to delete a read only file
 
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




Lee Crew wrote:

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


--

Dave Peterson

Lee Crew

How to delete a read only file
 
That worked perfectly many thanks for your help

"Dave Peterson" wrote:

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




Lee Crew wrote:

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


--

Dave Peterson



All times are GMT +1. The time now is 02:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com