Copying and pasting help

Hi,

Part of a database we have allows users to select multiple documents and then hit a button which brings up a form and allows them to enter a ‘standard response/answer’ for those questions.

The code behind this fills in some respective fields on the response documents (eg, question number etc). The code also creates a word document which attaches itself to the response document and fills into the word document what the users had entered in the ‘standard response/answer’ field.

What I’d like to do is get rid of the Word document and just have the ‘standard response/answer’ get filled into a form on the response document itself. The code at the moment copies the response from a temporary field into the clipboard and then pastes it back into the word document. The code which copies the text is shown below (it does this on QueryClose):

Sub Queryclose(Source As Notesuidocument, Continue As Variant)

Dim Workspace As New NotesUiWorkspace

Dim Session As New NotesSession

Dim SelectedQuestions As NotesItem



 '// If the user presses cancel then dont do anything

If Source.Document.CreateDocuments(0) = "No" Then

	Exit Sub

End If



 '// Copy the Entered Text and place it into the clipboard

Call Source.GotoField("StandardResponse")

On Error Goto InsertAndCopyDummyText          

Call Source.SelectAll()     

Call Source.Copy()

On Error Resume Next





 '// Begin Creating the Advice for each selected Document

Set SelectedQuestions = Source.Document.GetFirstItem("SelectedQuestions")



 '// Create the Advice Documents

If (Source.Document.DocumentType(0) = "Advice") Then

	Call CreateBulkAdviceForMany(SelectedQuestions)          

Else

      '// Create the Answer Documents

	Call CreateBulkAnswerForMany(SelectedQuestions)          

End If

Exit Sub

InsertAndCopyDummyText:

Call Source.InsertText(" ")

Call Source.SelectAll()     

Resume

End Sub

This is the code which creates the actual answer form - I’d like to use code here to somehow paste what’s on the clipboard into a field in the answer document. I’m not sure how to navigate to the field I want and then paste it in. The code I’ve looked at for pasting only talks about uidocument, which I don’t think will work for me.

Sub CreateAnswer(SelectedQuestions() As String, AdviceDocument As NotesDocument, PasteAnswer As Integer)

Dim WorkSpace As New NotesUiWorkSpace 

Dim Session As New NotesSession

Dim QuestionsAnswered As NotesItem

Dim QuestionsAnsweredFullName As NotesItem

Dim QoNDatabase As NotesDatabase

Dim NewAnswerDocument As NotesDocument

Dim AnswerText As NotesRichTextItem

Dim Added(0) As String

Dim AuthorsList As NotesItem

Dim ReadersList As NotesItem



Dim QuestionCount As Integer

Dim QuestionDocument As NotesDocument



 '// Get the current database

Set QoNDatabase = Session.CurrentDatabase



 '// Create the new Answer document

Set NewAnswerDocument = New NotesDocument(QoNDatabase)

NewAnswerDocument.Form = "Answer"

NewAnswerDocument.AnswerStatus = "Creation"

NewAnswerDocument.AuditTrail = ""

NewAnswerDocument.CreationDate = Now()

Call PopulateAnswerIDNumber(NewAnswerDocument)

Set AuthorsList = New NotesItem(NewAnswerDocument, "AuthorsList", Session.UserName, AUTHORS)

Set ReadersList = New NotesItem(NewAnswerDocument, "ReadersList", Session.UserName, READERS)



 '// Is it a Bulk Answer?

NewAnswerDocument.BulkAnswer = "Y"

NewAnswerDocument.DocumentSaved = "Y"



 '// Get the Question document details using the Universal ID

For QuestionCount = 0 To Ubound(SelectedQuestions())

      '// Get each Question document details

	Set QuestionDocument = GetDocumentByUNID(SelectedQuestions(QuestionCount)) 

	Redim Preserve ParliamentNumberList(QuestionCount)

	Redim Preserve SessionNumberList(QuestionCount)

	Redim Preserve HouseRaisedInList(QuestionCount)

	Redim Preserve QuestionNumberList(QuestionCount)

	Redim Preserve QuestionDetailsList(QuestionCount)

	QuestionNumberList(QuestionCount) = QuestionDocument.QuestionNumber(0)

	HouseRaisedInList(QuestionCount) = QuestionDocument.HouseRaisedIn(0)

	ParliamentNumberList(QuestionCount) = QuestionDocument.ParliamentNumber(0)

	SessionNumberList(QuestionCount) = QuestionDocument.Session(0)

	QuestionDetailsList(QuestionCount) = Cstr(Cstr(ParliamentNumberList(QuestionCount)) + _

	"/" + SessionNumberList(QuestionCount) + "/" + HouseRaisedInList(QuestionCount) + _

	"/" + QuestionNumberList(QuestionCount))

Next     



 '// Set the default Questions Answered values to the SelectedQuestions

Set QuestionsAnswered = New NotesItem(NewAnswerDocument, "QuestionsAnswered", "")     

NewAnswerDocument.QuestionsAnswered = QuestionDetailsList

Set QuestionsAnsweredFullName = New NotesItem(NewAnswerDocument, "QuestionsAnsweredFullName","")

Call UpdateFullNameQuestionList(NewAnswerDocument, QuestionsAnswered, QuestionsAnsweredFullName)



 '// Make it a response of the question document

Call NewAnswerDocument.MakeResponse(QuestionDocument)



If Not(AdviceDocument Is Nothing) Then

      '// Save the AnswerDocument so that it allows the addition of a rich text field.

	Call NewAnswerDocument.Save(False, False)

      '// Add the attachment

	Call AddPrevAdviceTemplateToAnswer(AdviceDocument, NewAnswerDocument)

End If



If PasteAnswer Then

      '// Add the rich text

	Set AnswerText = New NotesRichTextItem(NewAnswerDocument, "AnswerText")

      '// Save the Answer Document so we can add a rich text field

	Call NewAnswerDocument.Save(False, False)

      '// Create and Embed the OLE Object

	Call CreateAndEmbedOLEAdvice(QuestionDocument, NewAnswerDocument, AnswerText)

End If



 '// Save the Answer Document so we can add a rich text field

Call NewAnswerDocument.Save(False, False)



 '// Add the Link to the Document

Added(0) = Cstr(QuestionDocument.ParliamentNumber(0)) + "/" + Cstr(QuestionDocument.Session(0)) + "/" + _

Cstr(QuestionDocument.HouseRaisedIn(0)) + "/" + Cstr(QuestionDocument.QuestionNumber(0)) 



 '// Set the Access Lists

Call SetAnswerAccessLists(NewAnswerDocument)

End Sub

HOpe this all makes sense. I’m not sure if I should be looking at doing this another way besides copying and pasting text from the clipboard.

Thanks.