I have a module with the code below. When I click on my browse button, it open the generic directory dialogue box. I can not locate where in the code it is defining the path to open the directory dialogue box. Can anyone please help me find out what part of the code is generating the directory dialogue box so I can modify it to open to a specific server path, such as \\server123\Folder1\Folder2.
Option Compare Database
Option Explicit
Private Type BrowseInfo
hwndOwner As Long
pidlRoot As Long
sDisplayName As String
sTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Private Declare Function SHBrowseForFolder Lib "shell32.dll" (bBrowse As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" (ByVal lItem As Long, ByVal sDir As String) As Long
' Let the user browse for a directory. Return the
' selected directory. Return an empty string if
' the user cancels.
Public Function BrowseForDirectory() As String
Dim browse_info As BrowseInfo
Dim item As Long
Dim dir_name As String
'modified for MS Access/VBA
With browse_info
' .hwndOwner = Application.hWndAccessApp
.pidlRoot = 0
.sDisplayName = Space$(260)
.sTitle = "Select Directory"
.ulFlags = 1 ' Return directory name.
.lpfn = 0
.lParam = 0
.iImage = 0
End With
item = SHBrowseForFolder(browse_info)
If item Then
dir_name = Space$(260)
If SHGetPathFromIDList(item, dir_name) Then
BrowseForDirectory = Left(dir_name, _
InStr(dir_name, Chr$(0)) - 1)
Else
BrowseForDirectory = ""
End If
End If
End Function
Thanks.
Brandon
Option Compare Database
Option Explicit
Private Type BrowseInfo
hwndOwner As Long
pidlRoot As Long
sDisplayName As String
sTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Private Declare Function SHBrowseForFolder Lib "shell32.dll" (bBrowse As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" (ByVal lItem As Long, ByVal sDir As String) As Long
' Let the user browse for a directory. Return the
' selected directory. Return an empty string if
' the user cancels.
Public Function BrowseForDirectory() As String
Dim browse_info As BrowseInfo
Dim item As Long
Dim dir_name As String
'modified for MS Access/VBA
With browse_info
' .hwndOwner = Application.hWndAccessApp
.pidlRoot = 0
.sDisplayName = Space$(260)
.sTitle = "Select Directory"
.ulFlags = 1 ' Return directory name.
.lpfn = 0
.lParam = 0
.iImage = 0
End With
item = SHBrowseForFolder(browse_info)
If item Then
dir_name = Space$(260)
If SHGetPathFromIDList(item, dir_name) Then
BrowseForDirectory = Left(dir_name, _
InStr(dir_name, Chr$(0)) - 1)
Else
BrowseForDirectory = ""
End If
End If
End Function
Thanks.
Brandon