Tuesday, April 17, 2012

Get all the Design Elements - NotesNoteCollection

Everyone had this experience on their first exercise that getting the design element names.

We have two different ways.,

1. STEP- 1 : For getting the design elements name in our own view.

2. We can get it from NotesNoteCollection. Actually I tried to get the DXL (DOM object) from one of my non accessed database. Their I remembered the thing which I suffered in my past. Use of NotesNoteCollection is easy.

Please follow this code:-


On Error GoTo e
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim stream As NotesStream
Set stream = session.CreateStream
Dim filename As String
filename$ = "D:\dxl\" & Left(db.FileName, Len(db.FileName) - 3) & "dxl"
If Not stream.Open(filename$) Then
Messagebox "Cannot open " & filename$,, "Error"
Exit Sub
End If
Call stream.Truncate

REM Create note collection for current database
Dim nc As NotesNoteCollection
Set nc = db.CreateNoteCollection(False)
'Call nc.SelectAllDesignElements(True)
nc.SelectForms=true
Call nc.BuildCollection
Dim nid As String
nid=nc.Getfirstnoteid()
MsgBox nc.count
For i=1 To nc.Count
Dim doc As NotesDocument
nextid=nc.Getnextnoteid(nid)
Set doc=db.Getdocumentbyid(nid)
MsgBox doc.Getitemvalue("$Title")(0)
nid=nextid
Next
REM Export note collection as DXL
Dim exporter As NotesDXLExporter
Set exporter = session.CreateDXLExporter(nc, stream)
Call exporter.Process
MsgBox "Finished :)"
Exit Sub
e:
MsgBox "Error : " &Error &Erl() &" -- " &Err
Exit sub


The above is used to get the names of our forms in current database,

No comments:

Post a Comment