tramite vba è possibile cambiare la proprietà/attributo di tutti i files
presenti nella dir "C:\1opus\1_doc\" ed in tutte le sue sotto directory sì
da togliere ai files l'atttrbuto di sola lettura?
Grazie.
>tramite vba è possibile cambiare la proprietà/attributo di tutti i files
>presenti nella dir "C:\1opus\1_doc\" ed in tutte le sue sotto directory sì
>da togliere ai files l'atttrbuto di sola lettura?
Con una shell exec di attrib -r ad esempio.
G
'-----------------------------------------
Ciao Maurizio,
Prova:
'=============>>
Sub Prova()
SetFileAttributes sPath:="C:\1opus\1_doc\", _
iAttributes:=0
'(0= Normale, 1 = Sola lettura)
End Sub
'<<=============
'=============>>
Function SetFileAttributes(Optional sPath As String, _
Optional iAttributes As Long = 0)
Static oFSO As Object
Dim oSubFolder As Object
Dim oFolder As Object
Dim oFile As Object
Dim oFiles As Object
If oFSO Is Nothing Then
Set oFSO = CreateObject("SCripting.FileSystemObject")
End If
If sPath = "" Then
sPath = CurDir
End If
Set oFolder = oFSO.GetFolder(sPath)
Set oFiles = oFolder.Files
For Each oFile In oFiles
oFile.Attributes = iAttributes
Next oFile
For Each oSubFolder In oFolder.SubFolders
SetFileAttributes oSubFolder.Path
Next
End Function
'<<=============
---
Regards,
Norman
> ma sembrerebbe funzionare solo per la directory e non x tutti i files
> delle
> sue sottodirectory
Colpa mia!
>> SetFileAttributes oSubFolder.Path
Dovrebbe essere:
SetFileAttributes oSubFolder.Path, iAttributes
---
Regards,
Norman