Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2002-03-28
3
Medium Priority
?
460 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 800 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

704 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