ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Readonly files (https://www.excelbanter.com/excel-discussion-misc-queries/18220-readonly-files.html)

nc

Readonly files
 
Hi

How do I change all the files in a specified directory
from a read only file to a non read only file usig
macros. The macro should take in account that some files
might not be read only.

Thanks.

Bob Phillips

Sub ProcessFiles()
Dim sFolder As String
Dim Folder As Object
Dim file As Object
Dim Files As Object

Set FSO = CreateObject("Scripting.FileSystemObject")

sFolder = "C:\MyTest"
If sFolder < "" Then
Set Folder = FSO.GetFolder(sFolder)

Set Files = Folder.Files
For Each file In Files
If file.Attributes And 1 Then
'
Else
file.Attributes = file.Attributes + 1
End If
Next file

End If ' sFolder < ""

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"nc" wrote in message
...
Hi

How do I change all the files in a specified directory
from a read only file to a non read only file usig
macros. The macro should take in account that some files
might not be read only.

Thanks.




nc

Bob

Thanks a lot.


-----Original Message-----
Sub ProcessFiles()
Dim sFolder As String
Dim Folder As Object
Dim file As Object
Dim Files As Object

Set FSO = CreateObject("Scripting.FileSystemObject")

sFolder = "C:\MyTest"
If sFolder < "" Then
Set Folder = FSO.GetFolder(sFolder)

Set Files = Folder.Files
For Each file In Files
If file.Attributes And 1 Then
'
Else
file.Attributes = file.Attributes + 1
End If
Next file

End If ' sFolder < ""

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"nc" wrote in

message
...
Hi

How do I change all the files in a specified directory
from a read only file to a non read only file usig
macros. The macro should take in account that some

files
might not be read only.

Thanks.



.



All times are GMT +1. The time now is 05:05 AM.

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