Solved

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

Posted on 2002-03-28
3
448 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Suggested Courses

734 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