Link to home
Start Free TrialLog in
Avatar of Sjef Bosman
Sjef BosmanFlag for France

asked on

How can I add a picture from a file to a rich-text item using LotusScript?

I have a form with a hotspot action. When clicked, it will show an OpenFileDialog, so the user can select a picture file. When the user made his selection, I want the content of the file to be put into a hidden rich-text item with the name Logo. Is there a method to Import the file into the rich-text item? The existing Import method needs an open NotesUIDocument with the focus in the rich-text field, but I want to get the picture myself. In fact, the document is shown using a form in a DialogBox, hence rich-text fields cannot be used.

Here's what I tried:

Sub Click(Source As Button)
      Dim ws As New NotesUIWorkspace
      Dim files As Variant
      Dim doc As NotesDocument
      Dim rtitem As Variant
      Dim eo As notesEmbeddedObject
      
      files= ws.openfiledialog(False, "Select picture file", "All pictures|*.jpg;*.jpeg;*.gif|JPEG|*.jpg;*.jpeg|GIF|*.gif|Bitmap (not recommended)|*.bmp|All files|*.*|")
      If Isempty(files) Then Exit Sub
      Set doc= ws.CurrentDocument.Document
      doc.LogoFile= files(0)
      Call doc.RemoveItem("Logo")
      Set rtitem= New NotesRichTextItem(doc,"Logo")
      Set eo= rtitem.EmbedObject( 1453, "", files(0))
End Sub

How to do this?
Avatar of HemanthaKumar
HemanthaKumar

Using import method of NotesUIDoc is the only option I can think of



~Hemanth
Upgrade to R6, and use passtru html :-)

That's a solution that will work both on the web and in Notes...

Instead of embedding as object, you would embed it as attachment....

cheers,

Tom
Avatar of Sjef Bosman

ASKER

Nice thought Tom, but it's supposed to be R5/R6 compatibut... Web doesn't support DialogBoxes anyway, so native Notes will do.

Importing can only be done in a focused rich-text field, which I don't have in a DialogBox. SOme explanation: I use a DialogBox to present the db's configuration. Looks awesome, 99% works, just this %$#%$# logo-file!

No tricks up your sleeves? No fiddling?  In the distance I can hear someone say "Midas"... No, native Notes please, API but no DLL, that's all too difficult.
Sorry buddy, with this many restrictions I would say Lotus has to come up with this as a new enhancement
They already have my long short-list. Maybe I should embed it as a Microsoft Paint object? Why do I always have to ask questions without a solution? No that's not a new question! I could do with some *sob* consolation...

But hey, the day ain't over yet :)
ASKER CERTIFIED SOLUTION
Avatar of qwaletee
qwaletee

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Pls explain:
- create temp. document, import, etc: would this mean that the user sees the Import flashing by on his screen?? not such a problem, I'd like your view.
- open a new page with dialogbox look&feel?? it is really a document, with lots of fields.

Me first:
- no, I don't have to show the logo, at all actually.
- I let the user select the filename from his pc and would like to have only the picture that's in the file in the RT-item.
- there is no document beneath the DialogBox! An agent calls the DialogBox with a doc-parameter, in the QueryClose the document gets saved ("is that possible?" "yes it is, looks great!").
- I already thought RenderTo... but your angle is new and interesting
Q: Points are yours!

- screen flashes indeed, but it's a one-time-only exercise usually during installation
- I had to add a Sleep(1) in a loop to check for the saved document with the logo, before I can call RenderTo
- even the see-through gif-pictures come over nicely!

Thanks for the push.