I want to display Dialog to select file and put path to field because it’s attachment file.But i do not know how to do that ?
Subject: Try: fName = NotesUIWorkspace.Prompt(12, “”, “”)
If Notes Client:
Subject: How can I program to Display Dialog open to get file ?
Okay, this is an agent i have which i can execute from anywhere. It will simply export the complete path to an environment variable called “PathSelected”. Anything inside of the stars are just to show you which code goes where. So here goes:
(Declarations)************
Type BROWSEINFO
hwndOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
Hwnd As Long
End Type
Const BIF_BROWSEFORCOMPUTER = 1000
Const BIF_BROWSEFORPRINTER = 2000
Const BIF_DONTGOBELOWDOMAIN = 2
Const BIF_RETURNFSANCESTORS = 8
Const BIF_RETURNONLYFSDIRS = 1
Const BIF_STATUSTEXT = 4
Const MAX_SIZE = 255
Declare Function BrowseFolderDlg Lib “shell32.dll” Alias “SHBrowseForFolder” (lpBrowseInfo As BROWSEINFO ) As Long
Declare Function GetPathFromIDList Lib “shell32.dll” Alias “SHGetPathFromIDList” ( Byval PointerToIDList As Long, Byval pszPath As String ) As Long
Declare Function GetActiveWindow Lib “user32” () As Long
End of (Declarations)**********
Initialize*******
Sub Initialize
Dim session As New NotesSession
Dim path As String
path = OpenBrowseForFolderDialog("Choose folder to detach attachments to...", GetActiveWindow())
'Messagebox(path)
rightChar = Strrightback(Path,"\")
If path <> "You cancelled the operation" And rightChar <> "" Then
newpath = path + "\"
Else
newpath = path
End If
Call session.SetEnvironmentVar( "PathSelected", newpath)
End Sub
End of Initialize**********
Paste the below outside of the Initialize function to create new function**********
Function OpenBrowseForFolderDialog(DialogTitle As String, Owner As Long) As String
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession 'Declare session and set it to the current Notes Session
Dim db As NotesDatabase 'Declare db as type NotesDatabase
Dim source As NotesUIDocument 'Declare uidoc as type NotesDocument
Dim mBrowseInfo As BROWSEINFO
Dim mPointerToIDList As Long
Dim mResult As Long
Dim mPathBuffer As String
Dim sReturn As String
Set source = workspace.CurrentDocument
Set db = session.CurrentDatabase
Dim Clientdoc As NotesDocument
Set ClientView = db.GetView( "clients" )
clientn = source.FieldGetText("Client")
Set Clientdoc = ClientView.GetDocumentByKey(clientn)
’ this string is returned as result if you have canceled the action
sReturn = "You cancelled the operation"
'With mBrowseInfo
’ set parent window (owner of this window)
mBrowseInfo.hwndOwner = Owner
’ set start folder (0=desktor folder)
'Currently cannot use a variable as the value seems to always change
'mBrowseInfo.pidlRoot = Clientdoc.DefaultFolderID(0)
mBrowseInfo.pidlRoot = 0
’ dialog title
mBrowseInfo.lpszTitle = DialogTitle
’ pointer to a buffer that receives the display name of the folder selected by the user
mBrowseInfo.pszDisplayName = String(MAX_SIZE, Chr(0))
’ value specifying the types of folders to be listed in the dialog box as well as other options
mBrowseInfo.ulFlags = BIF_RETURNONLYFSDIRS
'End With
’ returns a pointer to an item identifier list that specifies the location of the selected folder relative to the root of the name space
mPointerToIDList = BrowseFolderDlg(mBrowseInfo)
If mPointerToIDList <> 0& Then
’ create a buffer
mPathBuffer = String(MAX_SIZE, Chr(0))
’ now get the selected path
mResult = GetPathFromIDList(Byval mPointerToIDList, Byval mPathBuffer)
’ returned path
'This sReturn returns the Pathname
sReturn = Left(mPathBuffer, Instr(mPathBuffer, Chr(0)) - 1) 'and return just that
End If
OpenBrowseForFolderDialog = sReturn
End Function
END OF AGENT***************
Good Luck!!
Subject: RE: How can I program to Display Dialog open to get file ?
Hi Stephen,Nice code !!
i guess you forgot to remove the following lines:
Dim Clientdoc As NotesDocument
Set ClientView = db.GetView( “clients” )
clientn = source.FieldGetText(“Client”)
Set Clientdoc = ClientView.GetDocumentByKey(clientn)
cheers!!
Subject: RE: How can I program to Display Dialog open to get file ?
Well spotted, forgot all about those.Remnants from when i was trying to get it to work ![]()
Cheers!