BarryL
Well-known Member
- Joined
- Jan 20, 2014
- Messages
- 1,436
- Office Version
- 2019
- Platform
- Windows
- MacOS
Hi All,
As per the title, I am having an issue with iterating through folders and files where the path exceeds the charater limits. Below is my code:
The code runs fine for me because I have my drives mapped, but the person I am sending it to cannot map their drives appropriately, so I am wondering is there a way around the character limit?
the error I am getting is "path not found" on the below line:
the subfolder path has exceeded the character limit and is now equal to "Nothing" in the locals window.
Does anyone know a way around this that doesn't include mapping? Also, is it possible to get the "Author" using FSO or can that only be done from shell?
As per the title, I am having an issue with iterating through folders and files where the path exceeds the charater limits. Below is my code:
Code:
Sub test()
Dim FileSystem As Object
Dim HostFolder As String
HostFolder = Sheet1.Range("F16").Value
If HostFolder = "" Then
MsgBox "No folder selected"
Exit Sub
End If
Set FileSystem = CreateObject("Scripting.FileSystemObject")
DoFolder FileSystem.GetFolder(HostFolder)
End Sub
Sub DoFolder(Folder As Scripting.Folder)
Dim SubFolder As Scripting.Folder, folderStr As String
For Each SubFolder In Folder.SubFolders
Sheet1.Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Value = SubFolder.Path
Sheet1.Range("B" & Range("B" & Rows.Count).End(xlUp).Row + 1).Value = SubFolder.DateLastModified
DoFolder SubFolder
Next
Dim File As Scripting.File
For Each File In Folder.Files
Sheet1.Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Value = File.Path
Sheet1.Range("B" & Range("B" & Rows.Count).End(xlUp).Row + 1).Value = File.DateLastModified
Next
End Sub
The code runs fine for me because I have my drives mapped, but the person I am sending it to cannot map their drives appropriately, so I am wondering is there a way around the character limit?
the error I am getting is "path not found" on the below line:
Code:
For Each SubFolder In Folder.SubFolders
the subfolder path has exceeded the character limit and is now equal to "Nothing" in the locals window.
Does anyone know a way around this that doesn't include mapping? Also, is it possible to get the "Author" using FSO or can that only be done from shell?
Last edited: