Here's the VBA code I'm using in MS Access (from Microsoft's support site - no edits):
**
Private Sub Command3_Click()
Dim fso As New FileSystemObject
Dim f As Folder, sf As Folder, path As String
'Initialize path.
path = Environ("windir")
'Get a reference to the Folder object.
Set f = fso.GetFolder(path)
'Iterate through subfolders.
For Each sf In f.SubFolders
Debug.Print sf.Name
Next
End Sub
**
I have also created the directory "C:\Test" and tried path = "C:\Test\" and path = "C:\Test" I am aware that the reference "Microsoft Scripting Runtime" needs to be enabled - and it is.
The code compiles without error. Despite the above, I'm still getting Run-time Error '13' Type Mismatch when I try to run it.
Is there anything else I'm doing wrong?