Skip to main content
    Country/region select      Terms of use
     Home      Products      Services & solutions      Support & downloads      My account     

developerWorks  >  Lotus  >  Forums & community  >  Best Practice Makes Perfect

Best Practice Makes Perfect

A collaboration with Domino developers about how to do it and how to get it right in Domino

[Update: de-encrypted attachment, please try again! Sorry...]
Someone asked in the Notes 6/7 Forum about a way to take screenshots off the clipboard and turn them into file attachments. I responded with a rough outline of a solution, but this is the sort of interesting problem that bugs me until I have working code. So, rather than leave it at that, I paid little attention to M. Hercule Poirot on TV as I slapped together some bits I already had, with a little new glue, and voila! Snap a screenshot, click this toolbar icon from any rich text field, and you get a file attachment in the rich text. The image files, of course, are not left behind to clutter up your disk.

The zipped attachment contains one NSF file. Put it in your local Notes data directory, and open it once. It will record its location in an INI variable so that the toolbar button can find it later. The About document contains the formula for the toolbar button (the Text Properties toolbar might be a good place for it).

Just to make it clearer what this does for you: I use a screenshot tool to capture a rectangle from my screen:


I put the cursor in a rich text field, and click the handy little toolbar icon:


I am prompted for a filename for the attachment:


A file attachment magically appears at the cursor location.


And if I use the View function I can see the original screenshot.

Here's the zipped database:

I designed this so that you could add it to an application fairly easily, in case you have a database that has a lot of pasted graphics and you want to have this feature in it. The application uses three forms, including one that's opened in a dialog, one that launches the dialog, and one that cleans up the temporary files afterward. I had to do this to make the "use from anywhere" part work, but if it's part of your application, you only need one form; you can open the dialog with an agent instead of composing a "launcher" document, and run another agent for cleanup after you create the attachment(s).

Incidentally, if you already have a screenshot that was pasted into a document and you want to convert it to an attachment, this will also work for that -- just copy it from the Notes rich text and click the toolbar. You can do several images at a time this way if you don't mind them having the same filenames with consecutive numbers added.

Andre Guirard | 13 February 2008 03:15:00 AM ET | Home, Plymouth, MN, USA | Comments (11)


1) Database is encrypted
Karsten Lehmann | 2/13/2008 4:26:59 AM

Your zipped database cannot be opened because it' encrypted.

2) I’m gonna have to dig into this...
Charles Robinson | 2/13/2008 9:40:21 AM

Thanks for sharing! This is going to be interesting to pull apart. :-) I've done it from VB and it was a monumental amount of pain and required diving into DirectX API.

3) encyption error
Lars Berntrop-Bos | 2/13/2008 9:43:47 AM

The error I get in Notes 8:


IBM Lotus Notes


Attempted encryption operation is not supported by this version of Notes.




4) oops
Andre Guirard | 2/13/2008 10:39:28 AM

will try again...

5) that’s better!
Lars Berntrop-Bos | 2/13/2008 6:57:11 PM

Now I can open it...

6) Runs under Notes 7 but...
Jens Winkelmann | 2/13/2008 7:26:15 PM have to comment out two rows in the Body field onFocus event of the ImagePateAttach form.

This properties of the DXL export class do not exist in Notes 7.

' DXL-export the document

Dim dxle As NotesDXLExporter

Set dxle = session.CreateDXLExporter(doc)

'dxle.OmitMiscFileObjects = True

dxle.ConvertNotesbitmapsToGIF = True ' otherwise they aren't a valid file format

'dxle.OmitOLEObjects = True

Dim domp As NotesDOMParser

Set domp = session.CreateDOMParser(dxle, )


7) re: Runs under Notes 7 but...
Andre Guirard | 2/13/2008 8:32:46 PM

Rats. Better yet, put On Error Resume Next ... before those statements.

I've updated the attachment once again to take this version difference into account. Keep those corrections coming!

8) Cool
Ronel Jonker | 2/14/2008 3:05:04 AM

This is so cool. Just what I needed today to get the embedded images from a nsf design to an external application in .gif format!! So easy!!!

Thanks for sharing this, Andre!!!!

9) CooL !
Dan Soares | 2/14/2008 11:14:16 AM

Thanks for sharing this tool Andre!

10) Turn clipboard image into GIF attachment
Ricahrd Fenwick | 2/20/2008 1:39:05 PM

Andre this is really useful, thanks

11) Turn clipboard image into GIF attachment
Alexander | 6/19/2008 7:08:04 AM

Works very well with Notes 8 - thanks, great job!

 Add a Comment
Comment:  (No HTML - Links will be converted if prefixed http://)
Remember Me?     Cancel

Search this blog 


    About IBM Privacy Contact