Reputation: 0 Apprentice
- Active Posts:
- 48 (0.05 per day)
- 06-August 12
- Profile Views:
- Last Active:
- Feb 13 2015 06:32 PM
- Dream Kudos:
Posts I've Made
Posted 13 Feb 2015
' Add reference to fileScriptingObject!! Dim wrkFSO As New Scripting.FileSystemObject Dim wrkFolder As String Dim strStartPath As String Dim FS As New FileSystemObject Dim FSfolder As Folder Dim subfolder As Folder Private Sub Form_Load() strStartPath = "C:\" ListFolder strStartPath End Sub Private Sub ListFolder(sFolderPath As String) Set FSfolder = FS.GetFolder(sFolderPath) ' There may better ways to use the 'If-Then-Else', but I like to keep code readable ' I came from an AS/400 RPG environment!! For Each subfolder In FSfolder.SubFolders If Len(subfolder) = 5 Then If subfolder <> "C:\hp" Then If subfolder <> "C:\VA" Then If subfolder <> "C:\BI" Then If subfolder <> "C:\VD" Then frm02List.AddItem subfolder End If End If End If End If End If Next subfolder Set FSfolder = Nothing End Sub
Posted 12 Feb 2015Here's a screencast that shows how to use code tags.
Note also that you don't need to quote a previous post each time, there is a Reply button further down the page.
Can not find the 'Reply" button.
Also, I will have to study the code formatting rules to fully understand on how to do it.
Thanks for you help!!
Posted 12 Feb 2015
Posted 11 Feb 2015Not sure you can filter the DirList how you want to (but may be mistaken).
Depending on what you want to filter it for, then you could look at using the FileSystemObject and filtering it manually.
In this link, there are a couple of examples of listing folders in a loop. You should be able to adapt one of these to only store the ones that meet your criteria (by length or whatever you need).
Thanks, it worked perfectly!!
Posted 10 Feb 2015Andrewsw,
thanks for the reply. My problem is that some of the folders have 2 character names (ie "C:\FC"). These I want to display .
- Member Title:
- New D.I.C Head
- Age Unknown
- Birthday Unknown
- Click here to e-mail me
geoleob hasn't added any friends yet.