I have the code shown below that someone suggested to me, but I need to change it so that a specific directory is given as starting point for users to then browse for folders to be placed in a user form listbox.
I have no idea what to change to make this happen. Any advise would be appreciated.
The starting point will always be: T:\\Finance\SohoMaccs\2018maccs\Monthly Reports\
I have no idea what to change to make this happen. Any advise would be appreciated.
The starting point will always be: T:\\Finance\SohoMaccs\2018maccs\Monthly Reports\
Code:
Private Sub UserForm_Initialize()
Dim oFolder As Object, oSubFolder As Object
Dim sFoldersList As String
Const SF_DOCUMENTS As Long = 5
sFolder = CreateObject("Shell.Application").Namespace(CVar(SF_DOCUMENTS)).Self.Path
With CreateObject("Scripting.FileSystemObject")
Set oFolder = .GetFolder(sFolder)
On Error GoTo NextSubFolder ' Error 70 = Permission Denied
If oFolder.Subfolders.Count > 0 Then
For Each oSubFolder In oFolder.Subfolders
sFoldersList = sFoldersList & oSubFolder.Path & ";"
NextSubFolder:
Next
End If
End With
sFoldersList = Left(sFoldersList, Len(sFoldersList) - 1)
Me.lbFolder.List = Split(sFoldersList, ";")
Me.Frame2.Visible = False
Me.Frame3.Visible = False
End Sub