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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can an attachment be opened / extracted from Excel-VBA?

Status
Not open for further replies.

crpjaviman

Technical User
Jan 24, 2002
57
US
Hi,

I work at a company that has Lotus Notes 5.0.11 running on XP OS. I am trying to open, launch, or extract an attachment from within a Notes database to Excel or even to the Desktop as a file, doesn't matter. I have been able to get to the $File item but no further than that. I have put some of the code I am using but I am still testing this code.

Dim session As Object
Dim dbdoc As Object
Dim DocView As Object
Dim NotesN As Object
Dim obj As NotesEmbeddedObject
Dim doc, doc1 As Object

Set session = CreateObject("Notes.Notessession") 'create notes session
'Call session.Initialize
Set dbdoc = session.GetDatabase("Server", "UNBOpRpt.nsf")
Set DocView = dbdoc.GetView("Reports by date")
Call DocView.Clear
Set NotesN = DocView.GetAllDocumentsByKey(#12/11/2003#, False)
cnt = NotesN.Count 'Count is 3
Set doc = DocView.GetFirstDocument("Daily Report")
Set doc1 = doc.GetFirstItem("$FILE")
doc1.ExtractFile ("$FILE") 'This part is where the program hangs "Object does not support this property."

Can anyone lead down the right path? What am I doing wrong?

Thanks in advance,


Thanks,
crpjaviman [rockband]
 
Depending on whether the file is attached to the NotesDocument or to a Rich Text field, you'll need to use either

Set notesEmbeddedObject = notesRichTextItem.GetEmbeddedObject( name$ )

or

Set notesEmbeddedObject = notesDocument.GetAttachment( fileName$ )

both are conditional on you knowing the filename of the attachment first. From there, you can use this statement to detach the attachment to the local computer:

Call notesEmbeddedObject.ExtractFile( path$ )

I recommend checking out the Domino Designer Help file for examples on how to do the above.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top