reubendayal
Senior Member
- Outlook version
- Outlook 365 64 bit
- Email Account
- Office 365 Exchange
Hi All,
I am having difficulties making this code work.
What I am trying to achieve is to add a network drive's subfolder names in a Userform's Dropdown List. Unsure what I am doing wrong. Please help.
The code has been taken from here and adjusted to my requirement. - Find and List all Files and Folders in a Directory - VBA and VB.Net Tutorials, Education and Programming Services
Thanks so much!
I am having difficulties making this code work.
What I am trying to achieve is to add a network drive's subfolder names in a Userform's Dropdown List. Unsure what I am doing wrong. Please help.
The code has been taken from here and adjusted to my requirement. - Find and List all Files and Folders in a Directory - VBA and VB.Net Tutorials, Education and Programming Services
Code:
Sub
Dim employer As String
Dim objFSO As Object
Dim objFolder As Object
Dim objSubFolder As Object
'Create an instance of the FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get the folder object
Set objFolder = objFSO.GetFolder("T:\Network Drive\Customers\")
i = 1
'loops through each file in the directory and prints their names and path
For Each objSubFolder In objFolder.SubFolders
' 'print folder name
Debug.Print objSubFolder.Name
employer = objSubFolder.Name(i)
cbEmployer.AddItem employer
i = i + 1
employer = employer & vbCrLf
Next objSubFolder
End Sub
Thanks so much!