I have a piece of code for brwosing for folder, that worked perfectly under AC2003.
After changing to AC2010 it will crash at the red line.
Any idea ?
Thanks,
Tal
After changing to AC2010 it will crash at the red line.
Code:
Option Compare Database
'http://www.mvps.org/access/api/api0002.htm
'Code courtesy of Terry Kreft
Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Private Declare PtrSafe Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Declare PtrSafe Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Public Function fn_BrowseDirectory(BrowseDirectoryTitle As String, BrowseDirectoryFlags) As String
On Error GoTo errHere
Dim x As Long, bi As BROWSEINFO, dwIList As Long
Dim szPath As String, wPos As Integer
With bi
.hOwner = hWndAccessApp
.lpszTitle = BrowseDirectoryTitle
.ulFlags = BrowseDirectoryFlags
End With
[B][COLOR="Red"] dwIList = SHBrowseForFolder(bi)[/COLOR][/B]
szPath = Space$(512)
x = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)
If x Then
wPos = InStr(szPath, Chr(0))
fn_BrowseDirectory = Left$(szPath, wPos - 1)
Else
fn_BrowseDirectory = ""
End If
ExitHere:
Exit Function
errHere:
Call ErrorHandling("", "fn_BrowseDirectory", Err, Err.Description)
Resume ExitHere
End Function
Any idea ?
Thanks,
Tal