LotusScript COM: Evaluate / NotesDocument.Form

Could someone tell me how to create a new document in a database and apply a form to it, when using COM?

Example:

Dim $n = ObjCreate(“Lotus.NotesSession”)

Dim $db = ObjCreate(“Notes.NotesDatabase”)

Dim $doc = ObjCreate(“Notes.NotesDocument”)

$n.Initialize(“my password goes here”)

$db = $n.GetDatabase(“server/org”, “dbname.nsf”)

$doc = $db.CreateDocument()

Now, I want to apply a form to $doc.

I’m unable to utilize $doc.Form = “name of form”. I can’t see any other way to apply a form to my new document (or create a document directly with the form).

I’m trying to achieve the equivalent of @Command([Compose]);“my form name”

but even Evaluate seems to be failing for me.

I tried

$result = $n.Evaluate("@Command([Compose]);“my form name”, $doc)

‘requested action with this object has failed’…

Any help on how to apply a form on a document through COM by either method would be greatly appretiated…

Thanks in advance,

Subject: Easy solution and a few suggestions…

From your posting:Dim $n = ObjCreate(“Lotus.NotesSession”)

Dim $db = ObjCreate(“Notes.NotesDatabase”)

Dim $doc = ObjCreate(“Notes.NotesDocument”)

$n.Initialize(“my password goes here”)

$db = $n.GetDatabase(“server/org”, “dbname.nsf”)

$doc = $db.CreateDocument()

First, please make everyone happy and lose the “$” as in LotusScript these refer to Strings and would come as a suffix and never a prefix.

Second, please make everyone else happy and change your NotesSession variable from “n” to “s” or “sess” or “session”.

Lastly your fix: doc.ReplaceItemValue(“Form”, “your form name”)

Form is as reserved field - not a Property.

Good luck,

Scott