I am trying to write the correct code for folders and files in Access VBA. The code seems to work, but I don't think it is quite correct.
The code is :
Intellisense works correctly for the objects defined as Folder and File, but not for those defined as Object.Code:Dim fdrMainFolder As Folder Dim fdrSubFolder As Folder Dim fleFile As File Dim objFolder As Object Dim objFolderItem As Object Set gobjShell = New Shell Set gobjFSO = New FileSystemObject Set fdrMainFolder = gobjFSO.GetFolder(<path to main folder>) For Each fdrSubFolder In fdrMainFolder.SubFolders Set objFolder = gobjShell.Namespace(fdrSubFolder & "\") For Each fleFile In fdrSubFolder.Files Set objFolderItem = objFolder.ParseName(fleFile.Name) ...... Next
Should I be defining them in another way to get Intellisense to work?
Also, it is not exactly clear to me why I need to get objFolder for a directory, since I already have fdrSubFolder set.
Looking at the code through debug, fdrSubFolder has the full path name to the folder, but objFolder is just the name of the folder without the path. Clearly it is a different type of object to "Folder".