developerWorks  >  Lotus  >  Forums & community  >  Lotus Domino Document Manager (Domino.Doc) Forum

Lotus Domino Document Manager (Domino.Doc) Forum

developerWorks




Export Domino.doc documents to another Domino Database
Kenio Damasceno 05/19/2009 03:34 PM
Document migration All Releases All Platforms


If you want to export Domino.doc documents to another database i wrote this Agent to do the job.
You need to install domino.doc API

Sub Initialize
'Declare all API objects as Variants

Dim theApi As Variant
Dim theLibrary As Variant
Dim theCabinets As Variant
Dim theCabinet As Variant
Dim theBinder As Variant
Dim theDocuments As Variant
Dim theNewDocument As Variant
Dim theProfile As Variant
Dim Dbs As NotesDatabase
Dim dbsCab As NotesDatabase
Dim docAng As NotesDocument
Dim docNvo As NotesDocument
Dim ventrycol As notesviewentrycollection
Dim dbDoc As Notesdatabase
Dim doc As NotesDocument
Dim docNovo As NotesDocument
Dim rtitem As NotesRichTextItem
Dim ses As New NotesSession

'Create the Api object
Set theApi = CreateObject("DominoDoc.API")

'Connect to a domdoc server using Notes
Call theApi.SetNotesLogin("yourpassword")
Set theLibrary = theApi.GetLibrary("notes://server/dominodoclib.nsf")

'Get the Cabinets object from the Library
Set theCabinets = theLibrary.Cabinets
Set theCabinet = theLibrary.Cabinets("SISDOC")
'Get binders
Set theBinders = theCabinet.Binders

'Loop to get all Binders
Dim x As Long
x=theBinders.Count
For k = 0 To (x-1)
Set theBinder=theBinders.ItemByIndex(k)
Set theDocuments = theBinder.Documents
fichario$=theBinder.title
y = theDocuments.Count

' loop to get all documents in the binder
For i = 0 To ( y-1)
Set theNewDocument = theDocuments.ItemByIndex(i)

anexo$=theNewDocument.Filename
filename$="c:\domdoc\"& theNewdocument.FileName
If anexo$ <>"" Then
Call theNewDocument.GetContents(filename$)
End If
Set dbs = ses.CurrentDatabase
Set dbDoc = ses.GetDatabase("server","cabinet.nsf")
Set doc = dbDoc.GETDOCUMENTBYUNID( theNewDocument.UNIVERSALID)
'create notes document and put data from domdoc document (some fields are custom fields in my cabinet)
Set docNovo = dbs.CreateDocument
docNovo.form = "sisdoc"
docNovo.codemp = doc.codempresa(0)
docNovo.empresa = doc.empresa(0)
docNovo.dataenvio=doc.dataemit(0)
docNovo.empresa = doc.Empresa(0)
docNovo.tipoarq = doc.tipoarq(0)
docNovo.codemp = doc.codempresa(0)
docNovo.titulo = doc.Title(0)
docNovo.desc = doc.DescriptionOfDocument(0)
docNovo.datacreate = doc.CreateDate(0)
docNovo.codigo = doc.Código(0)
docNovo.binderTitle = fichario$
If anexo$<>"" Then
docNovo.flagAnexo="1"
Else
docNovo.flagAnexo="0"
End If
'attach file
If anexo$<>"" Then
Set rtitem = New NotesRichTextItem (docNovo, "anexo")
Set object = rtitem.EmbedObject (EMBED_ATTACHMENT, "", filename$)
Kill filename$
End If
Call docNovo.Save(True,False)
Next
Next
End Sub

Go back