Using “Copy selected as table” in embedded view & pasted in the same document

10 pts.
Tags:
Lotus Domino
Lotus Notes
Lotus Notes Development
Hi, The following code is for a button in an embedded view.. User select documents and press this button, the entries will be copied as table and pasted into a "Body" field in a new document. It's work very well BUT I need to be pasted into the "Body" field at the current document not a new document. Is there anyone who can help me with this? I'll be very thankful. Regards, Rebecka Sub Click(Source As Button) Dim s As New NotesSession Dim uiw As New NotesUIWorkspace Dim doc As NotesDocument Dim myDoc As NotesDocument Dim dc As NotesDocumentCollection Dim db As NotesDatabase Dim myDB As New NotesDatabase( "serverName", "dbname.nsf" ) Dim rtItem As NotesRichTextItem Dim uName As NotesName Dim n As Integer On Error Resume Next Set db = s.CurrentDatabase Set dc = db.UnprocessedDocuments n = dc.Count Set doc = dc.GetFirstDocument Set myDoc = New NotesDocument(myDB) myDoc.Form = "myForm" Set rtItem = New NotesRichTextItem(myDoc, "Body") ' Body is a field in "myForm" that the table will be copied into 'Create table Dim styles(1 To 5) As NotesRichTextParagraphStyle For i% = 1 To 5 Set styles(i%) = s.CreateRichTextParagraphStyle styles(i%).LeftMargin = 0 styles(i%).FirstLineLeftMargin = 0 If i% = 1 Then styles(i%).RightMargin = RULER_ONE_CENTIMETER * 3 'Names Elseif i% = 2 Then styles(i%).RightMargin = RULER_ONE_CENTIMETER * 2.5 'status Elseif i% = 3 Then styles(i%).RightMargin = RULER_ONE_CENTIMETER * 4 'city Elseif i% = 4 Then styles(i%).RightMargin = RULER_ONE_CENTIMETER * 3 ' companyName Elseif i% = 5 Then styles(i%).RightMargin = RULER_ONE_CENTIMETER * 5 'Comments End If Next Call rtitem.AppendTable(n+1 ,5, , RULER_ONE_INCH, styles) 'Populate table column title Dim richStyle As NotesRichTextStyle Set richStyle = s.CreateRichTextStyle richStyle.FontSize = 8 richStyle.Bold = True Call rtitem.AppendStyle(richStyle) Dim rtnav As NotesRichTextNavigator Set rtnav = rtitem.CreateNavigator Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL, 1) 'Names Call rtitem.BeginInsert(rtnav) Call rtitem.AppendText("Name") Call rtitem.EndInsert Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL, 2) 'status Call rtitem.BeginInsert(rtnav) Call rtitem.AppendText("Status") Call rtitem.EndInsert Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL, 3) 'city Call rtitem.BeginInsert(rtnav) Call rtitem.AppendText("City") Call rtitem.EndInsert Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL, 4) ' companyName Call rtitem.BeginInsert(rtnav) Call rtitem.AppendText("Company") Call rtitem.EndInsert Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL, 5) 'Comments Call rtitem.BeginInsert(rtnav) Call rtitem.AppendText("Comments") Call rtitem.EndInsert richStyle.Bold = False Call rtitem.AppendStyle(richStyle) 'Populate table contents For i%=1 To n Set doc = dc.GetNthDocument(i%) Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL) Call rtitem.BeginInsert(rtnav) Set uName = New NotesName(doc.dNames(0)) 'Names Call rtItem.AppendText(uName.Common) Call rtitem.EndInsert Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL) Call rtitem.BeginInsert(rtnav) Call rtItem.AppendText(doc.status(0)) 'status Call rtitem.EndInsert Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL) Call rtitem.BeginInsert(rtnav) Call rtItem.AppendText(doc.city(0)) 'city Call rtitem.EndInsert Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)  Call rtitem.BeginInsert(rtnav) Call rtItem.AppendText(doc.companyName(0)) ' companyName Call rtitem.EndInsert Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL) Call rtitem.BeginInsert(rtnav) Call rtItem.AppendText(doc.comments(0)) 'Comments Call rtitem.EndInsert Next Call rtItem.AddNewLine(2) Call myDoc.ComputeWithForm(False, False) Call uiw.EditDocument(True, myDoc) End Sub

Software/Hardware used:
Lotus Notes 8.5 server & klient, windows xp

Answer Wiki

Thanks. We'll let you know when a new response is added.

Try this :

1) Declare your uidoc object in a public variable in Declaration of your form :
Public uidocPublic as NotesUIDocument
2) Initialise it in a “post open” event of your form :
Dim ws as New NotesUIWorkspace
Set uidocPublic = ws.currentDocument
3) In your button code :
Call uidocPublic.Refresh( True )
Set myDoc = uidocPublic.Document
Set rtItem = myDoc.GetFirstItem( “Body”)
And then you code to paste …

Tell me if it works or not :-\

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following