Examples: Using OLE

  1. This example represents two command buttons on a Visual Basic form. The first button writes a new document in an existing Domino® database by creating a NotesSession object through OLE and creating NotesDatabase and NotesDocument objects through Notes® methods. The second button frees the memory used by the Domino® object before unloading the Visual Basic form.
    Private Sub Command1_Click()
      Dim session As Object
      Dim db As Object
      Dim doc As Object
      Set session = CreateObject("Notes.NotesSession")
      Set db = session.GetDatabase("", "test4.nsf")
      Set doc = db.CreateDocument()
      doc.Form = "Main Topic"
      doc.Subject = Form1.Text3.Text
      doc.Body = Form1.Text2.Text
      Call doc.Save(True, False)
    End Sub
    Private Sub Command2_Click()
      Set doc = Nothing
      Set db = Nothing
      Set session = Nothing
      Unload Form1
    End Sub
  2. This example represents a command button on a Visual Basic form. The button launches Notes® if it is not already running, and then opens test4.nsf in the local data directory.
    Private Sub Command3_Click()
      Dim ws As Object
      Set ws = CreateObject("Notes.NotesUIWorkspace")
      Call ws.OpenDatabase("", "test4.nsf")
    End Su