Lotus Notes, Sametime and Java working together

Sametime and Domino solutions
Lotus Notes/Domino and Sametime software made easy
 


Get notification about
updates

 

Show Explorer-style file dialog in Lotus Notes

This LotusScript agent is combined from different sources found on the Internet. It's functionality is similar to notesUIWorkspace.OpenFileDialog LotusScript method but it looks more like a standard Windows file dialog. Supports both single file and multiple files selection.


'Options section
Option Public
Option Declare
Public Const OFN_ALLOWMULTISELECT = &H200
Public Const OFN_CREATEPROMPT = &H2000
Public Const OFN_ENABLEHOOK = &H20
Public Const OFN_ENABLETEMPLATE = &H40
Public Const OFN_ENABLETEMPLATEHANDLE = &H80
Public Const OFN_EXPLORER = &H80000
Public Const OFN_EXTENSIONDIFFERENT = &H400
Public Const OFN_FILEMUSTEXIST = &H1000
Public Const OFN_HIDEREADONLY = &H4
Public Const OFN_LONGNAMES = &H200000
Public Const OFN_NOCHANGEDIR = &H8
Public Const OFN_NODEREFERENCELINKS = &H100000
Public Const OFN_NOLONGNAMES = &H40000
Public Const OFN_NONETWORKBUTTON = &H20000
Public Const OFN_NOREADONLYRETURN = &H8000
Public Const OFN_NOTESTFILECREATE = &H10000
Public Const OFN_NOVALIDATE = &H100
Public Const OFN_OVERWRITEPROMPT = &H2
Public Const OFN_PATHMUSTEXIST = &H800
Public Const OFN_READONLY = &H1
Public Const OFN_SHAREAWARE = &H4000
Public Const OFN_SHAREFALLTHROUGH = 2
Public Const OFN_SHARENOWARN = 1
Public Const OFN_SHAREWARN = 0
Public Const OFN_SHOWHELP = &H10

' Declarations section

Dim sFolder As String
Dim sFiles As String
Dim sFile As String
Dim vbNullChar
Dim aFiles() As Variant
Dim nNullPos As Integer
Dim n As Integer
Dim Filter As String
Dim FileName As String
Dim FileTitle As String
Dim TruncName As String
Dim VaultWIPRoot As String
Dim VaultWIPUserPath As String
Type tagOPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As Long
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
Flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As Long
End Type
Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (OPENFILENAME As tagOPENFILENAME) As Long
Dim OPENFILENAME As tagOPENFILENAME


' Main code

Function OpenCommDlg (allowMulti, initialTitle As String, initialDir As String)
Dim Title As String
Dim DefExt As String
Dim szCurDir As String
Dim APIResults%

Title =initialTitle & Chr$(0) 'Title of the dialog

FileName = Chr$(0) & Space$(255) & Chr$(0)
FileTitle = Space$(255) & Chr$(0)


'Set up the default directory
szCurDir = initialDir+Chr(0) 'Curdir$ & Chr$(0)

'Set up the data structure before you call the GetOpenFileName
OPENFILENAME.lStructSize = Len(OPENFILENAME)


'If the OpenFile Dialog box is not linked to any form use this line.
'It will pass a null pointer.

OPENFILENAME.hwndOwner = 0&

OPENFILENAME.lpstrFilter = Filter
OPENFILENAME.nFilterIndex = 1
OPENFILENAME.lpstrFile = FileName
OPENFILENAME.nMaxFile = Len(FileName)
OPENFILENAME.lpstrFileTitle = FileTitle
OPENFILENAME.nMaxFileTitle = Len(FileTitle)
OPENFILENAME.lpstrTitle = Title
OPENFILENAME.hInstance = 0
OPENFILENAME.lpstrCustomFilter = 0
OPENFILENAME.nMaxCustFilter = 0
OPENFILENAME.lpstrInitialDir = szCurDir
OPENFILENAME.nFileOffset = 0
OPENFILENAME.nFileExtension = 0
OPENFILENAME.lCustData = 0
OPENFILENAME.lpfnHook = 0
OPENFILENAME.lpTemplateName = 0

If allowMulti Then
OPENFILENAME.Flags = OFN_FILEMUSTEXIST Or OFN_ALLOWMULTISELECT Or OFN_EXPLORER
Else
OPENFILENAME.Flags = OFN_FILEMUSTEXIST Or OFN_EXPLORER
End If

'This will pass the desired data structure to the Windows API,
'which will in turn it uses to display the Open Dialog form.
APIResults% = GetOpenFileName(OPENFILENAME)

If APIResults% <> 0 Then
OpenCommDlg = 1
Else
OpenCommDlg = 0
End If

vbNullChar=Chr(0)
sFiles = Cstr( OPENFILENAME.lpstrFile )
nNullPos = Instr(sFiles, vbNullChar)

If nNullPos > OPENFILENAME.nFileOffset Then
' one file
sFiles = Left(sFiles, nNullPos - 1)
Redim aFiles(1 To 1)
aFiles(1) = sFiles
Else
' multiple files
sFolder = Left(sFiles, nNullPos - 1)
sFiles = Mid(sFiles, nNullPos + 1)
nNullPos = Instr(sFiles, vbNullChar)

n = 0
Do While nNullPos > 1
sFile = sFolder & "\" & Left(sFiles, nNullPos - 1)
sFiles = Mid(sFiles, nNullPos + 1)
n = n + 1
Redim Preserve aFiles(1 To n)
aFiles(n) = sFile
nNullPos = Instr(sFiles, vbNullChar)
Loop
End If
End Function

Sub Initialize
Filter="Word Documents (*.doc)"& Chr(0) & "*.doc" & Chr(0) & _
"PDF Documents (*.pdf)"& Chr(0) & "*.pdf" & Chr(0) & _
"Programs (*.exe)" & Chr(0) & "*.exe" & Chr(0) & _
"Compressed files (*.zip)" & Chr(0) & "*.zip" & Chr(0) & _
"All (*.*)" & Chr(0) & "*.*" & Chr(0)

'Parameters are:
Allow multi-selection, Title , Initial folder

If (OpenCommDlg(True, "Choose files", "c:\downloads") = 1) Then
Forall v In aFiles
Msgbox v
End Forall
Else
Msgbox "No documents were selected."
End If

End Sub


Example output from this agent:








© Copyright 2004. Botstation