Shell32.dll

BrowseForFolder 
SHGetPathFromIDList 

SHBrowseForFolder and SHGetPathFromIDList

These two functions are not compatible with 64 bit.

Declare Function SHBrowseForFolder Lib "shell32.dll" (lpBrowseInfo As BROWSEINFO) As Long 
Declare Function SHGetPathFromIDList Lib "shell32.dll" (ByVal pidl As Long, ByVal pszPath As String) As Long

If you are using these APIs to browse for a folder you should replace your code with this:

link - learn.microsoft.com/en-us/windows/win32/shell/shell-browseforfolder 
Enum vbShellGetFolderFlags
  BIF_RETURNONLYFSDIRS = &H1
  BIF_DONTGOBELOWDOMAIN = &H2
  BIF_STATUSTEXT = &H4
  BIF_RETURNFSANCESTORS = &H8
  BIF_EDITBOX = &H10
  BIF_VALIDATE = &H20
  BIF_NEWDIALOGSTYLE = &H40
  BIF_BROWSEINCLUDEURLS = &H80
  BIF_BROWSEFORCOMPUTER = &H1000
  BIF_BROWSEFORPRINTER = &H2000
  BIF_BROWSEINCLUDEFILES = &H4000
  BIF_SHAREABLE = &H8000
  BIF_SHOWALLOBJECTS = &H8
End Enum

Const BIF_DefaultOptions = BIF_EDITBOX Or BIF_VALIDATE Or BIF_SHOWALLOBJECTS Or BIF_STATUSTEXT Or BIF_NEWDIALOGSTYLE
Const BIF_BrowseFolder = BIF_RETURNONLYFSDIRS Or BIF_DefaultOptions

Public Sub Example_ShellGetFolder()
   Debug.Print ShellGetFolder("Select the folder")
End Sub

Public Function ShellGetFolder(Caption As String) As String
Dim objShell As Object
Dim objBrowse As Object

   On Error GoTo ErrorHandler
   Set objShell = CreateObject("Shell.Application")
   Set objBrowse = objShell.BrowseForFolder(&H0, Caption, BIF_BrowseFolder, Chr(0))

   ShellGetFolder = objBrowse.Self.Path
   Exit Function
ErrorHandler:
   MsgBox Err.Description
End Function


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext