Domino Code Fragment

Code Name*
Open a document in edit mode if it exists.
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.216.233.58
Description*
Open a document in edit mode if it exists.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
The following code will open in edit mode the first doc in the "UPref" view if it exists or
create a new document if it doesn't exist. Use GetDocumentByKey on the view if you need to
select a specific document first.

Dim session As New Notessession
Dim ws As New NotesUIWorkspace
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument


Set db = session.CurrentDatabase
Set view = db.GetView("UPref")


On Error Resume Next
Set doc = view.GetFirstDocument
If doc Is Nothing Then
Set uidoc = ws.ComposeDocument("","","UPref")
Else
ws.OpenDatabase "","","UPref"
ws.EditDocument
End If