LotusScript to Paste Image in Excel - Memory Problem

My LN database document has a single picture (not attachment) in a rich text field and I’m trying to copy the picture and paste it into an MS Excel cell using LotusScript. The actual code has loops and ifs, but I’ve boiled it down to the code shown here. The view has a single document in it.

Sub Initialize

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Dim vAppObj As Variant

Dim uidoc As NotesUIDocument

Dim session As New NotesSession

Dim workspace As New NotesUIWorkspace

Dim BOPattach As NotesRichTextItem

On Error Goto processError

Set db = session.CurrentDatabase

Set view = db.GetView( “26068_V” )

Set doc = view.GetFirstDocument()

Set vAppObj = CreateObject ( “Excel.Application” )

vAppObj.Workbooks.Add

Set BOPattach = doc.GetFirstItem(“BOPAttach_R”)

Set uidoc = workspace.EditDocument(True, doc)

Call uidoc.GotoField(“BOPAttach_R”)

Call uidoc.SelectAll

Call uidoc.Copy

Call uidoc.Close(True)

vAppObj.Activesheet.Cells(2, 2).Select

vAppObj.Activesheet.Paste

vAppObj.Visible = True

Set vAppObj = Nothing

Exit Sub

processError:

Messagebox "Error " & Err() & “(” & Error() & “)”

Exit Sub

End Sub

The code works fine if the image is smaller than about 41 Kbytes. If the image is larger than that I get a pair of error messages. The first one is the Lotus Notes message “Insufficient memory.” The next one is the one from the error trap in the code: “Error 213(Microsoft Office Excel: Microsoft Office Excel cannot Paste the data).”

My highest hope is that the error can be eliminated completely and large images can be pasted. If that is not possible, then can the “Insufficient memory” message be suppressed so that a larger code with loops could resume without tipping the user that one image bombed?

I found an interesting clue. I tested total memory and memory used just before the paste operation. I Used vAppObj.MemoryTotal and vAppObj.MemoryUsed. Using a variety of image sizes and open applications, the memory numbers were the same. I always get 1228800 total memory and 180224 memory used. Could this mean that there is only a fixed amount of memory allocated at the time that the vAppObj object is created? If so, then how do I extend the amount of memory? By the way, is this number in bytes? I have a Gb of RAM on my computer.

I really do appreciate any help I can get on this. Thanks in advance.

Subject: LotusScript to Paste Image in Excel - Memory Problem

Hey there Scot.This may be grasping at straws, but have you tried pasting the image BEFORE closing the NotesUIDocument?

Set uidoc = workspace.EditDocument(True, doc)

Call uidoc.GotoField(“BOPAttach_R”)

Call uidoc.SelectAll

Call uidoc.Copy

vAppObj.Activesheet.Cells(2, 2).Select

vAppObj.Activesheet.Paste

vAppObj.Visible = True

Set vAppObj = Nothing

Call uidoc.Close(True)

-Devin.

Subject: RE: LotusScript to Paste Image in Excel - Memory Problem

Thank you for the suggestion Devin. I have now tried closing the uidoc after the paste and I get the same result.