[Webinar] Streamline your web hosting managementRegister Today


Copying a field value to clipboard in READ mode

Posted on 2000-02-08
Medium Priority
Last Modified: 2013-12-18
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!
Question by:mhazell
  • 4
  • 3
LVL 24

Accepted Solution

HemanthaKumar earned 400 total points
ID: 2501435

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

Author Comment

ID: 2503419
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...

LVL 24

Expert Comment

ID: 2503779
Sure, I would like to see that.

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.


Author Comment

ID: 2503996
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!

LVL 24

Expert Comment

ID: 2504077
Thank u very much for that info.

By the way are u from US... !


Author Comment

ID: 2504539
No, the UK (London)...

why do you ask?

LVL 24

Expert Comment

ID: 2504734
Just like that, Keep in touch.


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Get the source code for a fully functional Access application shell with several popular security features that Access VBA application developers desire, but find difficult or impossible to figure out how to code. You get the source code for managi…
Suggested Courses

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question