Lotusscript - How to Export Attachments

Hi,

I’m working on exporting some documents from Lotus Notes. I thought Word would be the best format for the output, and I have Lotusscript code that does export successfully. The problem I have is that one of the fields I need to export is a rich text field that sometimes has attachments (e.g. Word, PDF, Excel) in it. Does anyone know if it’s possible to export these as objects into Word?

Here’s my code which does work, but only the text is exported for the rich text field (rtDesc):

(Declarations)

Const wdCell = 12

Const wdLine =5

Const END_OF_TABLE = 6

Sub Initialize

…blah blah get NotesDocument docContact

'Create Word object	

Set vntWord = CreateObject("Word.Application")

vntWord.Visible = False

Call vntWord.Documents.Add

				

	With vntWord

		.ActiveDocument.PageSetup.LeftMargin = 40

		.ActiveDocument.Tables.Add vntWord.Selection.Range, 2, 6

		.Selection.Tables(1).Select

		'.Selection.Tables(1).Borders.Enable = True

		.Selection.Font.Size = 8 

		.Selection.Cells.Width = 90

		

		.Selection.Font.Bold = True

		.Selection.TypeText "Subject:"

		.Selection.MoveRight wdCell

		.Selection.Font.Bold = False

		.Selection.TypeText docContact.kwdSubject(0)

		

		.Selection.MoveRight wdCell

		.Selection.Font.Bold = True

		.Selection.TypeText "Division:"

		.Selection.MoveRight wdCell

		.Selection.Font.Bold = False

		.Selection.TypeText docContact.kwdDivision(0)

		

		.Selection.MoveRight wdCell

		.Selection.Font.Bold = True

		.Selection.TypeText "Business Area:"

		.Selection.MoveRight wdCell

		.Selection.Font.Bold = False

		.Selection.TypeText docContact.kwdBusArea(0)

		

			.Selection.MoveRight wdCell

			.Selection.Font.Bold = True

			.Selection.TypeText "Rule:"

			.Selection.MoveRight wdCell

			.Selection.Font.Bold = False

			.Selection.TypeText docContact.txtRule(0)						

		.Selection.EndKey END_OF_TABLE

		

		.Selection.TypeParagraph 

		.Selection.TypeParagraph

		.Selection.Font.Size = 8 

		.Selection.Font.Bold = True

		.Selection.TypeText "Description and/or Attachment:"

		.Selection.TypeParagraph

		.Selection.Font.Bold = False

		Set rtDesc = docContact.GetFirstItem("rtDesc")

		.Selection.TypeText rtDesc.Values

		

	End With



vntWord.Visible = True

…blah blah error trapping etc

Thanks in advance for any advice.

Subject: Lotusscript - How to Export Attachments - Solution

In case anyone else is looking for this, here’s the solution I came up with:

		'Check to see if there are any attachments

		If (Not Isempty(rtDesc.EmbeddedObjects)) Then

			Forall Object In rtDesc.EmbeddedObjects

				If (Object.Type = EMBED_ATTACHMENT) Then

			

					.Selection.TypeParagraph 

					Call Object.ExtractFile("f:\temp\" & Object.Source)



				'Insert the attachment into Word

.Selection.InlineShapes.AddOLEObject Object.Source, "f:\temp\" & Object.Source, , True, , , Object.Source



				End If

			End Forall

		End If

Hope this is of some help to someone.

Cheers!

Subject: RE: Lotusscript - How to Export Attachments - Solution

Hi

thanks for your script. I’m new in this area and I want ask if you can help.

I have a “Contact” nsf DB. I try to export the contact name, phone and so on into a SQL Database. That works fine if the DB field is a text field. But now I have a RTF field which contains the Body of a Note, Email or Fax message. How can I export this? Perfect would be if I can export the attached documents as well. But the pure text without style informations would be ok for the moment too. I think I need a LotusScript for that, right? Can anyone help with that? I found some good information here about the RTF problem, but I never used a LotusScript before - so I’m confused now how I can start.

I create the text field exports over the DominoDesigner and a View.

Thanks a lot.