Tip

Select Folder - From Api

Have you ever wanted to show user that dialog which allows to select ONLY THE
FOLDER to save files? Well, this piece of code can do that for you. I've put
this and a lot of others functions API functions in a script library, i don't
need to tell you why...
Put the first part in Declarations Section, and the rest as a function, that
returns the path selected. It's perfect when you need to select ONLY A FOLDER,
and not a file.
Have fun...
'--------------------------------------------------
'BrowseFolder
'--------------------------------------------------
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
Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias
"SHGetPathFromIDListA" (Byval pidl As Long, Byval pszPath As String) As Long
Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA"
(lpBrowseInfo As BROWSEINFO) As Long


Function BrowseFolder (path As String, windowtitle As String) As String

Dim X As Long, bi As BROWSEINFO, dwIList As Long
Dim wPos As Integer
Dim cam2 As String

bi.pszDisplayName = path
bi.hOwner = hWndAccessApp
bi.lpszTitle = title
bi.ulFlags = BIF_RETURNONLYFSDIRS

dwIList = SHBrowseForFolder (bi)
cam2 = Space$(512)
X = SHGetPathFromIDList(Byval dwIList, Byval cam2)

If X Then
wPos = Instr (cam2, Chr(0))
BrowseFolder = Left$ (cam2, wPos - 1)
Else
BrowseFolder = ""
End If

End Function





Example:

Sub Click (Source As Button)

Dim session As New notessession
Dim wk As New notesuiworkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim folder As String
Set uidoc = wk.CurrentDocument
Set doc = uidoc.Document
folder = BrowseFolder (doc.CERT_Destination(0), "Choose the folder to save
ID File:")
If folder <> "" Then
Call uidoc.FieldSetText ("CERT_Destination", folder + "\")
Call session.SetEnvironmentVar ("CERT_Destination", folder + "\")
End If

End Sub

This was first published in November 2000

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.