Copying a field value to clipboard in READ mode

I have a database of 'answers' that users can read but cannot edit. Part of the functionality they require is a 'copy answer to clipboard' which should take the ANSWERTEXT field of the current answer document and put it into the clipboard (for later pasting into a Word document etc).
However i'm at a loss of how to do this - the methods i've seen involve putting the document into edit mode and using UIDOC.COPY for example (which cannot be done due to security restrictions).
Please help!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


Sounds pretty

Design a Subform with a field name DispAnswerText (Editable) and default value as AnswerText . Whenever user clicks the button, Open the Dialog and use editcopy (both using @Commands )

Here we Go:

In the button write this code:
@DialogBox( "subformname" ; [AutoHorzFit] : [AutoVertFit] : [NoCancel] : [NoNewFields] : [NoFieldUpdate] ; "Copy Text" );

On the Subform

Postopen event:

QueryClose event:
@Command([EditGotoField] ; "DispAnswerText");
@Command([EditCopy]) ;


you will have the data in the clipboard....

Good Luck

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mhazellAuthor Commented:
Thanks for the quick answer. This is indeed a solution to my problem, however because it displays the dialog very briefly it is probably not quite suitable in this case.

While experimenting with this though, i did find what appears to be a cracking bug in Notes (4.6.3): I took the dialog form and made it all hidden. However as a side effect of this, whenever i clicked the action to copy to clipboard, it shut Notes down completely - highly amusing!

As it happens i was actually also sent a script that uses the API (windows DLLs) to copy the field to the clipboard - i can post it here if anybody expresses an interest...

Sure, I would like to see that.

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

mhazellAuthor Commented:
This was sent to me by Rudy Crespin - my thanks to him:

This goes in (Options):
‘dataformat ID for ANSI text with ending null (\0). CR(13)/ LF(10) are for end of line.
Const CF_TEXT = &H001

This goes in (Declarations):
Declare Function OpenClipboard Lib “User32.dll” Alias “OpenClipboard” (Byval hWnd As Long) As Long Declare Function EmptyClipboard Lib “User32.dll” Alias “EmptyClipboard” ( )
As Long
Declare Function SetClipboardData Lib “User32.dll” Alias “SetClipboardData” (Byval wFormat As Integer,Byval hAnsiText As Long ) As String Declare Function GetClipboardData Lib “User32.dll” Alias “GetClipboardData” (Byval wFormat As Integer) As String Declare Function CloseClipboard Lib “User32.dll” Alias “CloseClipboard” ( )
As Long
Declare Function MYlstrcpy Lib “Kernel32.dll” Alias “lstrcpyA” (Byval Buffer
As Long, Byval COPYString As String) As Long
Declare Function GlobalAlloc Lib “Kernel32.dll” Alias “GlobalAlloc” (Byval
wFlags As Long, Byval dwBytes As Long) As Long
Declare Function GlobalLock Lib “Kernel32.dll” Alias “GlobalLock”(Byval hMem
As Long) As Long
Declare Function GlobalUnlock Lib “Kernel32.dll” Alias “GlobalUnlock” (Byval
hMem As Long) As Long
Declare Function GlobalFree Lib “Kernel32.dll” Alias “GlobalFree” (Byval
hMem As Long) As Long

This goes in the Click event for a button:
Sub Click(Source As Button)
Dim Status As Long
Dim ptr As Long, ghand As Long,handle As Long
Dim Text As String
Dim workspace As New NotesUIWorkspace
Dim Uidoc As NotesUIDocument
Dim item As NotesItem
Dim s As New notessession
Dim db As NotesDatabase
Dim col As NotesDocumentCollection
Dim doc As notesDocument

Set db = s.currentdatabase
Set col = db.unprocesseddocuments
Set doc = col.getfirstdocument

‘ Control of platform 16/32-Bit
If Instr(s.platform,”16”) Then
Messagebox (“Wrong Windows-platform; this agent runs only under Windows NT/95”)
Exit Sub
End If
‘ Select Notes field
Set item = doc.GetFirstItem(“xxxxxx”)
‘ open clipboard
Status = OpenClipboard(handle)
If Status <> 0 Then

‘Delete clipboard contents
Status = EmptyClipboard()

‘get global storage for field contense ghand = GlobalAlloc(0,(Len(item.Values(0))+1))
‘lock global storage
ptr = GlobalLock(ghand)

‘copy contents of field to global storage
Status = MYlstrcpy(ptr,item.Values(0))

‘free global storage
Status = GlobalUnlock(ghand)

‘write to clipboard
Call SetClipboardData(CF_TEXT, ptr)

‘close clipboard
Status = CloseClipboard()

‘free handle of global storage
Status = GlobalFree(ghand)

Messagebox (“Error opening the clipboard!”)
Exit Sub
End If
End Sub

It works a beauty!

Thank u very much for that info.

By the way are u from US... !

mhazellAuthor Commented:
No, the UK (London)...

why do you ask?

Just like that, Keep in touch.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.