Solved

How to create a document w/  a specific form using LotusScript

Posted on 2002-03-28
3
444 Views
Last Modified: 2013-12-18
I need to be able to create a document in a notes database using a particular form named "test", set its variables to specific values, and perform a file attachment.

With the below code, I can successfully create a ducument, but I have been unable to create a document using a specific form.

Would like to create from scratch, but if I ahve to find the last one and clone it, etc. that's okay.  I just need something that works.


Note:

I am doing this from a VB app.


Sub cmdOpen_Click()


Dim db As New Domino.NotesDatabase
Dim session As New Domino.NotesSession

Dim object As Domino.NotesEmbeddedObject
Dim Body As Domino.NotesRichTextItem


' Set up error handling
On Error GoTo errhandler

' Create a Notes session
Set session = New Domino.NotesSession
 
 ' Initialize Notes Session
Call session.Initialize("thepassword")
 
 'Open the Notes Database
Set db = session.GetDatabase("", "test5.nsf")
 
If db.IsOpen = True Then
   Set doc = db.CreateDocument
    'Dim doc As New NotesDocument


     'doc.Form = "test"
     'doc.duration = 5
     'doc.JobCat = "test2"
     'doc.employee = s.UserName
     'doc.Customer = "Isn't this Cool?"
     'doc.Start = Now()
     'doc.End = Now()
     
    If (Body Is Nothing) Then Set Body = doc.CreateRichTextItem("Body")
    Set object = Body.EmbedObject(1454, "", "c:\test.txt")
    Call doc.Save(True, False)

             
 Else
        ' Put a messagebox or something here alerting user to fact that database could not bve opened.
 End If



 'Clean up memory
 Set doc = Nothing
 Set db = Nothing
 Set object = Nothing

Exit Sub
0
Comment
Question by:DLeader
  • 2
3 Comments
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 200 total points
ID: 6903495
The COM vary little bit, here is how your code becomes a workable one.

Dim session
Dim db
Dim object
Dim Body


' Set up error handling
'On Error GoTo errhandler

' Create a Notes session
Set session = CreateObject("Lotus.NotesSession")

' Initialize Notes Session
Call session.InitializeUsingNotesUserName("USER", "PASSWORD")
' Call session.Initialize("thepassword")



'Open the Notes Database
Set db = session.GetDatabase("", "test.nsf")

If db.IsOpen = True Then
    Set doc = db.CreateDocument
    Call doc.ReplaceItemValue("Form", "Test")
    Call doc.ReplaceItemValue("Duration", 5)
    Call doc.ReplaceItemValue("JobCat", "test2")
    Call doc.ReplaceItemValue("employee", session.UserName)
    Call doc.ReplaceItemValue("Customer", "Isn't this Cool?")
    Call doc.ReplaceItemValue("Start", Now())
    Call doc.ReplaceItemValue("End", Now())
    Set Body = doc.CreateRichTextItem("Body")
    Set object = Body.EmbedObject(1454, "", "c:\test.txt")
    Call doc.Save(True, False)
Else
       ' Put a messagebox or something here alerting user to fact that database could not bve opened.
End If



'Clean up memory
Set doc = Nothing
Set db = Nothing
Set object = Nothing

~Hemanth
0
 

Author Comment

by:DLeader
ID: 6903523
Excellent work.  I looked all over for this answer.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6903732
You are welcome anytime .
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question