BrianM
Well-known Member
- Joined
- Jan 15, 2003
- Messages
- 768
- Office Version
- 2016
- Platform
- Windows
Hello,
I found this code which I know will work, however, the first folder the code finds I don't have permission to open. What is the correct way to bypass this folder and move to the next?
Thanks,
Brian
I found this code which I know will work, however, the first folder the code finds I don't have permission to open. What is the correct way to bypass this folder and move to the next?
Thanks,
Brian
VBA Code:
Sub findFolder()
Dim searchFolderName As String
searchFolderName = "C:\Users\"
Dim FileSystem As Object
Set FileSystem = CreateObject("Scripting.FileSystemObject")
doFolder FileSystem.GetFolder(searchFolderName)
End Sub
Sub doFolder(Folder)
Dim subFolder
Dim subFolder2 As String
On Error Resume Next
For Each subFolder In Folder.subfolders
If Split(subFolder, "\")(UBound(Split(subFolder, "\"))) = "SSA HDT(s)" Then
subFolder2 = Right(subFolder, 25)
MsgBox "gotcha"
End
End If
doFolder subFolder
Next subFolder
End Sub