Friday, 30 May 2008

PromptForViewName

Function PromptForViewName( ) As String

Dim session As New NotesSession
Dim db As NotesDatabase
Dim viewsArray As Variant
Dim intSize As Integer
Dim i As Integer
Dim strViewName As String
Dim strDefaultName As String
Dim ws As New NotesUIWorkspace()

Set db = session.CurrentDatabase
viewsArray = db.Views

intSize = Ubound(viewsArray)
Redim strViewNamesArr(intSize) As String

Forall v In viewsArray
strViewNamesArr(i) = v.Name
If v.Name = "Contacts" Then
strDefaultName = "Contacts" ' if there is a contacts view, we will default to that
End If
i = i + 1

End Forall

'############################################
' Prompt for view name... default to contact if we have it
'############################################
If strDefaultName = "" Then
strDefaultName = strViewNamesArr(0)
End If

strViewName = ws.Prompt (PROMPT_OKCANCELLIST, _
"Select a View", _
"Select a view to use - (should have first column sorted.)", _
strDefaultName, strViewNamesArr)

If Isempty (strViewName) Then
strViewName = ""
End If

PromptForViewName = strViewName

End Function

No comments: