Coleman34
08-26-2014, 07:30 AM
So I am trying to select a folder and have VBA toggle the read only option on that folder. I am at a loss at the moment, probably brain lock. Any constructive help would be appreciated as I am relatively new to VBA functionality of this level.
Public Function ChangeReadOnly()
Dim oFSO
Dim oFolder
Dim oFile
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder("\myPath\targetFolder")
For Each oFile In oFolder
FileAtt = VBA.GetAttr(oFile.Path)
If FileAtt And vbReadOnly Then
Call VBA.SetAttr(oFile.Path, FileAtt = Not (vbReadOnly))
End If
End Function
Public Function ChangeReadOnly()
Dim oFSO
Dim oFolder
Dim oFile
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder("\myPath\targetFolder")
For Each oFile In oFolder
FileAtt = VBA.GetAttr(oFile.Path)
If FileAtt And vbReadOnly Then
Call VBA.SetAttr(oFile.Path, FileAtt = Not (vbReadOnly))
End If
End Function