Attribute VB_Name = "mod1Oefeningen"
Option Explicit
Sub Oefening1()
Dim fdVenster As FileDialog
Dim strMap As String
Set fdVenster = Application.FileDialog(msoFileDialogFolderPicker)
With fdVenster
.Title = "Selecteer een map"
If .Show = -1 Then strMap = .SelectedItems(1)
End With
MsgBox strMap
End Sub
Sub Oefening2()
Dim strMap As String
Dim strBestand As String
strMap = ActiveWorkbook.Path & "\Bronnen\"
strBestand = Dir(strMap & "*.txt")
Do While strBestand <> ""
Debug.Print strBestand
strBestand = Dir
Loop
End Sub
Sub Oefening3()
Dim objFSO As Object
Dim objMap As Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objMap = objFSO.getFolder(ActiveWorkbook.Path)
Set objMap = objMap.ParentFolder
gaMap objMap
End Sub
Sub gaMap(objMap)
Dim objSubMap As Object
Dim objBestand As Object
For Each objSubMap In objMap.SubFolders
Debug.Print objSubMap.Name
gaMap objSubMap
Next
For Each objBestand In objMap.Files
Debug.Print vbTab & objBestand.Name
Next
End Sub
Download hier het bestand.
