Monday, September 26, 2011

Open a document in edit mode if it exists.

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")
 ws.OpenDatabase "","","UPref"
End If

No comments:

Post a Comment