Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sample Code to Export the fields and attachment

Status
Not open for further replies.
Nov 25, 2002
33
0
0
MO
Finally, I could do the job, here is the sample code to export the fields and attachments for a notes database....., I have hardcode the "export path"
I could use this code to export the PDF, word and excel rather than rtf...

Sub Click(Source As Button)

Dim session As New NotesSession
Dim db As NotesDatabase

REM Opened Database
Set db = session.GetDatabase("swan", "test\memo",False)

If Not db.IsOpen Then
Messagebox "database cannot be opened",,"cannot opened"
Else
Messagebox db.Title,, "opened"
End If
REM ____________________________________________________________


REM Create note collection
Dim nc As NotesNoteCollection
Set nc = db.CreateNoteCollection(False)
Call nc.SelectAllNotes(True)
Call nc.BuildCollection

REM get doc
Dim doc As NotesDocument
Dim view As NotesView
Dim x As Integer


Set view = db.GetView( "ByIssuedDate" )
Set doc = view.GetFirstDocument
x = 0


Dim fileNum1 As Integer
Dim fileName1 As String
Dim object As NotesEmbeddedObject
Dim str1 As String
Dim att As NotesEmbeddedObject

fileNum1% = Freefile()
fileName1$ = "c:\export\memo\file.txt"

Open fileName1$ For Output As fileNum1%

While Not (doc Is Nothing)
x = x + 1
Forall i In doc.Items
Write #fileNum1%, x, " ", i.name, " ", doc.GetItemValue (i.name)(0)
If i.name = "$FILE" Then
str1= doc.GetItemValue(i.name)(0)
End If
End Forall
Set object = doc.GetAttachment(str1)
If Not (object Is Nothing) Then
Call object.ExtractFile("c:\export\memo\" & str1)
End If
Set doc = view.GetNextDocument(doc)
Wend
Write #fileNum1%, "Total Record = ", x
Close fileNum1%

End Sub

Kill Ghost Prince
 
I Can't get your code working from within MS Access; I must change the first part this way to get it working:

Code:
Dim db As Object          'The CasePackage database
Dim Session As Object    'The notes session
Dim dbname As String
    
Set Session = CreateObject("Notes.NotesSession")
dbname = "Api462re.nsf"

'Open the database in notes
Set db = Session.GetDatabase("", dbname)
    If Not db.IsOpen Then
        MsgBox "database cannot be opened", , "cannot opened"
    Else
        MsgBox db.Title, , "opened"
    End If
    Rem ____________________________________________________________
What about the remaining? How can I "port" it to VBA?
 
Here is the code using Lotus Script, I used the Lotus Designer to make the button, and write the code the the sub on_click() event, becasue of time restriction and I just use it for migration only (one time), I "hard code" the paths.

Kill Ghost Prince
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top