Setting the default directory using getDirectory

Joined
Jun 4, 2010
Messages
1
Reaction score
0
How can I use the getDirectory function but specify where I want the default directory to be? Right now, I'm using the getDirectory function and the Desktop directory automatically pops up. What if I want the C:\ directory to pop up for example?

This is what I'm using right now:

Function GetDirectory(Optional Msg) As String

Dim bInfo As BROWSEINFO
Dim path As String
Dim r As Long, x As Long, pos As Integer

bInfo.pidlRoot = 0&
If IsMissing(Msg) Then
bInfo.lpszTitle = "Select a folder."
Else
bInfo.lpszTitle = Msg
End If

' Type of directory to return
bInfo.ulFlags = &H1
' Display the dialog
x = SHBrowseForFolder(bInfo)

' Parse the result
path = Space$(512)
r = SHGetPathFromIDList(ByVal x, ByVal path)
If r Then
pos = InStr(path, Chr$(0))
GetDirectory = Left(path, pos - 1)
Else
GetDirectory = ""
End If

End Function

Thank you,
Melissa
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top