Forum Discussion
Problem with Shell32 object class in MS Access
- Feb 13, 2022this will work:
Dim Shel As Shell32.Shell, ShelFolder As Shell32.Folder, ShelObject As Shell32.FolderItem, iInt As Integer, iStr As String
iInt As Variant
Thank you. That may be better than the one I stumbled upon. It will depend on the incidence of casting issues as the functions and modules pass the item index variable into and through one another.
I discovered another solution that affects only the Set ShelObject statement leaving all variables as originally declared. I can set the ShellFolderItem object simply by setting it from the Shel.Namespace object directly. Shel.Namespace continues to accept Integer, Long, String and Varaint data types as inputs into the item index parameter, whereas the folder object (declared as type object) now only accepts variant as you suggest. In practice I would like to preserve the object hierachy Namespace > Folder > FolderItem in the code. I'll take a close look at both alternatives. Here is what I found.
A sub having...
Dim Shel As shell32.Shell, ShelFolder As Object, ShelObject As ShellFolderItem
Dim iInt As Integer
and comparing the following blocks of code to set the FolderItemObject
this statement works...
Set ShelObject = Shel.NameSpace("C:\Program Files (x86)\Windows Media Player").Items.Item(iInt)
while this fails...
Set ShelFolder = Shel.NameSpace("C:\Program Files (x86)\Windows Media Player")
ShelObject = ShelFolder.Items.Item(iInt)