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