Monday, July 16, 2007

Microsoft Excel Worksheet (Embedded Object)

Today I did a simple task, but I never do it before. So, I had a simple form with Microsoft Excel Worksheet (Embedded Object). My task was to extract this embedded object from notes's documents to disk in folder. I had 2 problems:
- how I can choose a folder on my own PC from Lotus Notes client?
- how I can extract object as MS Excek file and save it in chosen folder?

the first task I solved by using undocumented method of NotesUIWorkspace: Let folderTo = w.prompt(14, "", "")

second task I solved by using next code:

If doc.HasEmbedded Then
Forall o In doc.EmbeddedObjects
Set handle = o.Activate(True)
If Not handle Is Nothing Then
Set exWb = handle.Application.ActiveWorkBook

'
Let VNumber = doc.GetItemValue("VNumber")(0)
Let Agreement_1 = doc.GetItemValue("Agreement_1")(0)
Let fileName = VNumber & SEP & Agreement_1 & ".xls"
'


On Error Resume Next
Call exWb.SaveAs(folderTo & fileName)
Print {Operate with file '} & folderTo & fileName & {'}
On Error Goto ERR_THIS
End If
End Forall
End If

No comments :